home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 10 / BBS In A Box Volume X (AMUG) (January 1994).bin / Files / Prog / U-Z / VideoToolBox.cpt / VideoToolboxSources / Luminance.c < prev    next >
MacBinary  |  1993-03-04  |  37.5 KB  |  [TEXT/KAHL]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Thu Mar 4 02:16:39 1993, modified Thu Mar 4 02:16:39 1993, creator Think C, type ASCII, 37750 bytes "Luminance.c" , at 0x93f6 428 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[KAHL]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0b 4c 75 6d 69 6e 61 | 6e 63 65 2e 63 00 00 00 |..Lumina|nce.c...|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4b 41 48 | 4c 01 00 00 00 00 00 00 |.TEXTKAH|L.......|
|00000050| 00 00 00 00 00 93 76 00 | 00 01 ac a7 bb 5d 57 a7 |......v.|.....]W.|
|00000060| bb 5d 57 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.]W.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 cb 1b 00 00 |........|........|
|00000080| 2f 2a 0d 4c 75 6d 69 6e | 61 6e 63 65 2e 63 0d 56 |/*.Lumin|ance.c.V|
|00000090| 65 72 73 69 6f 6e 20 31 | 2e 39 35 0d 53 65 65 20 |ersion 1|.95.See |
|000000a0| 4c 75 6d 69 6e 61 6e 63 | 65 2e 68 20 66 6f 72 20 |Luminanc|e.h for |
|000000b0| 70 72 6f 74 6f 74 79 70 | 65 73 2e 0d 53 65 65 20 |prototyp|es..See |
|000000c0| 4c 75 6d 69 6e 61 6e 63 | 65 2e 64 6f 63 20 66 6f |Luminanc|e.doc fo|
|000000d0| 72 20 65 78 70 6c 61 6e | 61 74 69 6f 6e 2e 0d 41 |r explan|ation..A|
|000000e0| 6c 73 6f 20 73 65 65 3a | 0d 44 2e 47 2e 20 50 65 |lso see:|.D.G. Pe|
|000000f0| 6c 6c 69 20 61 6e 64 20 | 4c 2e 20 5a 68 61 6e 67 |lli and |L. Zhang|
|00000100| 20 28 31 39 39 31 29 20 | 41 63 63 75 72 61 74 65 | (1991) |Accurate|
|00000110| 20 63 6f 6e 74 72 6f 6c | 20 6f 66 20 63 6f 6e 74 | control| of cont|
|00000120| 72 61 73 74 20 6f 6e 20 | 6d 69 63 72 6f 63 6f 6d |rast on |microcom|
|00000130| 70 75 74 65 72 20 64 69 | 73 70 6c 61 79 73 2e 20 |puter di|splays. |
|00000140| 0d 56 69 73 69 6f 6e 20 | 52 65 73 65 61 72 63 68 |.Vision |Research|
|00000150| 2c 20 33 31 3a 31 33 33 | 37 2d 31 33 36 30 2e 0d |, 31:133|7-1360..|
|00000160| 0d 43 6f 70 79 72 69 67 | 68 74 20 28 63 29 20 31 |.Copyrig|ht (c) 1|
|00000170| 39 38 39 2d 31 39 39 33 | 20 44 65 6e 69 73 20 47 |989-1993| Denis G|
|00000180| 2e 20 50 65 6c 6c 69 2e | 20 54 68 69 73 20 73 6f |. Pelli.| This so|
|00000190| 66 74 77 61 72 65 20 69 | 73 20 66 72 65 65 3b 20 |ftware i|s free; |
|000001a0| 79 6f 75 20 6d 61 79 20 | 75 73 65 20 69 74 20 69 |you may |use it i|
|000001b0| 6e 0d 79 6f 75 72 20 72 | 65 73 65 61 72 63 68 20 |n.your r|esearch |
|000001c0| 61 6e 64 20 67 69 76 65 | 20 69 74 20 61 77 61 79 |and give| it away|
|000001d0| 20 74 6f 20 6f 74 68 65 | 72 73 2c 20 77 69 74 68 | to othe|rs, with|
|000001e0| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 72 | the fol|lowing r|
|000001f0| 65 73 74 72 69 63 74 69 | 6f 6e 73 2e 20 41 6e 79 |estricti|ons. Any|
|00000200| 0d 63 6f 70 79 20 79 6f | 75 20 67 69 76 65 20 61 |.copy yo|u give a|
|00000210| 77 61 79 20 6d 75 73 74 | 20 69 6e 63 6c 75 64 65 |way must| include|
|00000220| 20 74 68 69 73 20 70 61 | 72 61 67 72 61 70 68 2c | this pa|ragraph,|
|00000230| 20 75 6e 6d 6f 64 69 66 | 69 65 64 2c 20 61 6e 64 | unmodif|ied, and|
|00000240| 2c 20 69 66 20 79 6f 75 | 20 68 61 76 65 0d 6d 61 |, if you| have.ma|
|00000250| 64 65 20 61 6e 79 20 63 | 68 61 6e 67 65 73 20 74 |de any c|hanges t|
|00000260| 6f 20 74 68 65 20 72 65 | 73 74 20 6f 66 20 74 68 |o the re|st of th|
|00000270| 65 20 66 69 6c 65 2c 20 | 6d 75 73 74 20 69 6e 63 |e file, |must inc|
|00000280| 6c 75 64 65 20 61 20 6e | 6f 74 65 2c 20 61 64 64 |lude a n|ote, add|
|00000290| 65 64 20 74 6f 20 48 49 | 53 54 4f 52 59 0d 62 65 |ed to HI|STORY.be|
|000002a0| 6c 6f 77 2c 20 67 69 76 | 69 6e 67 20 79 6f 75 72 |low, giv|ing your|
|000002b0| 20 6e 61 6d 65 2c 20 74 | 68 65 20 64 61 74 65 2c | name, t|he date,|
|000002c0| 20 61 6e 64 20 61 20 64 | 65 73 63 72 69 70 74 69 | and a d|escripti|
|000002d0| 6f 6e 20 6f 66 20 74 68 | 65 20 63 68 61 6e 67 65 |on of th|e change|
|000002e0| 73 2e 20 54 68 69 73 0d | 73 6f 66 74 77 61 72 65 |s. This.|software|
|000002f0| 20 6d 61 79 20 6e 6f 74 | 20 62 65 20 73 6f 6c 64 | may not| be sold|
|00000300| 2c 20 77 68 65 74 68 65 | 72 20 69 6e 20 73 6f 75 |, whethe|r in sou|
|00000310| 72 63 65 20 6f 72 20 63 | 6f 6d 70 69 6c 65 64 20 |rce or c|ompiled |
|00000320| 66 6f 72 6d 2c 20 77 69 | 74 68 6f 75 74 20 6d 79 |form, wi|thout my|
|00000330| 0d 70 65 72 6d 69 73 73 | 69 6f 6e 2e 20 49 20 68 |.permiss|ion. I h|
|00000340| 6f 70 65 20 79 6f 75 20 | 77 69 6c 6c 20 66 69 6e |ope you |will fin|
|00000350| 64 20 74 68 69 73 20 73 | 6f 66 74 77 61 72 65 20 |d this s|oftware |
|00000360| 75 73 65 66 75 6c 2c 20 | 62 75 74 20 49 20 63 61 |useful, |but I ca|
|00000370| 6e 27 74 20 70 72 6f 6d | 69 73 65 20 74 68 61 74 |n't prom|ise that|
|00000380| 0d 69 74 20 77 69 6c 6c | 20 77 6f 72 6b 20 66 6f |.it will| work fo|
|00000390| 72 20 79 6f 75 2c 20 61 | 6e 64 20 61 6d 20 6e 6f |r you, a|nd am no|
|000003a0| 74 20 6f 66 66 65 72 69 | 6e 67 20 61 6e 79 20 73 |t offeri|ng any s|
|000003b0| 75 70 70 6f 72 74 2e 20 | 54 68 61 74 27 73 20 77 |upport. |That's w|
|000003c0| 68 79 20 69 74 27 73 20 | 66 72 65 65 2e 20 49 0d |hy it's |free. I.|
|000003d0| 77 6f 75 6c 64 20 61 70 | 70 72 65 63 69 61 74 65 |would ap|preciate|
|000003e0| 20 72 65 70 6f 72 74 73 | 20 6f 66 20 62 75 67 73 | reports| of bugs|
|000003f0| 20 61 6e 64 20 69 6d 70 | 72 6f 76 65 6d 65 6e 74 | and imp|rovement|
|00000400| 73 2e 0d 0d 44 65 6e 69 | 73 20 47 2e 20 50 65 6c |s...Deni|s G. Pel|
|00000410| 6c 69 2c 20 50 68 2e 44 | 2e 0d 49 6e 73 74 69 74 |li, Ph.D|..Instit|
|00000420| 75 74 65 20 66 6f 72 20 | 53 65 6e 73 6f 72 79 20 |ute for |Sensory |
|00000430| 52 65 73 65 61 72 63 68 | 2c 20 53 79 72 61 63 75 |Research|, Syracu|
|00000440| 73 65 20 55 6e 69 76 65 | 72 73 69 74 79 2c 20 53 |se Unive|rsity, S|
|00000450| 79 72 61 63 75 73 65 2c | 20 4e 59 20 31 33 32 34 |yracuse,| NY 1324|
|00000460| 34 2d 35 32 39 30 2c 20 | 55 2e 53 2e 41 2e 0d 64 |4-5290, |U.S.A..d|
|00000470| 65 6e 69 73 5f 70 65 6c | 6c 69 40 69 73 72 2e 73 |enis_pel|li@isr.s|
|00000480| 79 72 2e 65 64 75 0d 0d | 48 49 53 54 4f 52 59 3a |yr.edu..|HISTORY:|
|00000490| 0d 0d 34 2f 32 34 2f 38 | 39 20 64 67 70 20 66 69 |..4/24/8|9 dgp fi|
|000004a0| 72 73 74 20 77 6f 72 6b | 69 6e 67 20 76 65 72 73 |rst work|ing vers|
|000004b0| 69 6f 6e 2e 0d 34 2f 32 | 38 2f 38 39 20 64 67 70 |ion..4/2|8/89 dgp|
|000004c0| 20 61 64 64 65 64 20 64 | 65 76 69 63 65 20 61 72 | added d|evice ar|
|000004d0| 67 75 6d 65 6e 74 2e 0d | 36 2f 32 33 2f 38 39 20 |gument..|6/23/89 |
|000004e0| 64 67 70 20 61 64 64 65 | 64 20 73 75 70 70 6f 72 |dgp adde|d suppor|
|000004f0| 74 20 66 6f 72 20 61 20 | 76 69 64 65 6f 20 61 74 |t for a |video at|
|00000500| 74 65 6e 75 61 74 6f 72 | 20 74 68 61 74 20 68 61 |tenuator| that ha|
|00000510| 73 20 75 6e 65 71 75 61 | 6c 20 67 61 69 6e 20 69 |s unequa|l gain i|
|00000520| 6e 20 74 68 65 20 74 68 | 72 65 65 0d 09 09 09 63 |n the th|ree....c|
|00000530| 68 61 6e 6e 65 6c 73 2e | 20 41 64 64 65 64 20 4c |hannels.| Added L|
|00000540| 6f 61 64 43 6c 75 74 28 | 29 20 61 6e 64 20 4c 75 |oadClut(|) and Lu|
|00000550| 6d 69 6e 61 6e 63 65 43 | 6c 75 74 28 29 20 72 6f |minanceC|lut() ro|
|00000560| 75 74 69 6e 65 73 2e 0d | 37 2f 33 30 2f 38 39 20 |utines..|7/30/89 |
|00000570| 64 67 70 20 72 65 70 6c | 61 63 65 64 20 63 61 6c |dgp repl|aced cal|
|00000580| 6c 20 74 6f 20 53 65 74 | 45 6e 74 72 69 65 73 20 |l to Set|Entries |
|00000590| 28 77 68 69 63 68 20 63 | 61 6c 6c 73 20 74 68 65 |(which c|alls the|
|000005a0| 20 43 6f 6c 6f 72 20 4d | 61 6e 61 67 65 72 29 20 | Color M|anager) |
|000005b0| 62 79 20 61 20 63 61 6c | 6c 0d 09 09 09 74 6f 20 |by a cal|l....to |
|000005c0| 47 44 53 65 74 45 6e 74 | 72 69 65 73 20 28 77 68 |GDSetEnt|ries (wh|
|000005d0| 69 63 68 20 63 61 6c 6c | 73 20 74 68 65 20 64 65 |ich call|s the de|
|000005e0| 76 69 63 65 20 64 72 69 | 76 65 72 29 2e 0d 38 2f |vice dri|ver)..8/|
|000005f0| 31 30 2f 38 39 20 64 67 | 70 20 66 69 78 65 64 20 |10/89 dg|p fixed |
|00000600| 62 75 67 73 2e 0d 38 2f | 31 33 2f 38 39 20 64 67 |bugs..8/|13/89 dg|
|00000610| 70 20 72 65 77 72 6f 74 | 65 20 4c 54 6f 56 28 29 |p rewrot|e LToV()|
|00000620| 20 74 6f 20 75 73 65 20 | 6e 74 68 20 6f 72 64 65 | to use |nth orde|
|00000630| 72 20 70 6f 6c 79 6e 6f | 6d 69 61 6c 2e 20 42 72 |r polyno|mial. Br|
|00000640| 6f 6b 65 20 75 70 20 4c | 69 6e 65 61 72 69 7a 65 |oke up L|inearize|
|00000650| 43 6c 75 74 20 69 6e 74 | 6f 0d 09 09 09 74 68 72 |Clut int|o....thr|
|00000660| 65 65 20 72 6f 75 74 69 | 6e 65 73 2d 2d 53 65 74 |ee routi|nes--Set|
|00000670| 4c 75 6d 69 6e 61 6e 63 | 65 52 61 6e 67 65 2c 20 |Luminanc|eRange, |
|00000680| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 2c 20 61 6e |SetLumin|ance, an|
|00000690| 64 20 53 65 74 4c 75 6d | 69 6e 61 6e 63 65 73 2d |d SetLum|inances-|
|000006a0| 2d 74 68 65 0d 09 09 09 | 6c 61 73 74 20 6f 66 20 |-the....|last of |
|000006b0| 77 68 69 63 68 20 69 73 | 20 65 71 75 69 76 61 6c |which is| equival|
|000006c0| 65 6e 74 20 74 6f 20 74 | 68 65 20 6f 6c 64 20 4c |ent to t|he old L|
|000006d0| 69 6e 65 61 72 69 7a 65 | 43 6c 75 74 2e 0d 38 2f |inearize|Clut..8/|
|000006e0| 31 36 2f 38 39 09 64 67 | 70 09 41 66 74 65 72 20 |16/89.dg|p.After |
|000006f0| 72 65 61 64 69 6e 67 20 | 74 68 65 20 42 72 6f 6f |reading |the Broo|
|00000700| 6b 74 72 65 65 20 44 41 | 43 20 6d 61 6e 75 61 6c |ktree DA|C manual|
|00000710| 20 49 20 63 68 61 6e 67 | 65 64 20 74 68 65 20 64 | I chang|ed the d|
|00000720| 6f 63 75 6d 65 6e 74 61 | 74 69 6f 6e 20 61 6e 64 |ocumenta|tion and|
|00000730| 0d 09 09 09 69 6e 63 72 | 65 61 73 65 64 20 74 6f |....incr|eased to|
|00000740| 6c 65 72 61 6e 63 65 20 | 66 72 6f 6d 20 30 2e 35 |lerance |from 0.5|
|00000750| 20 74 6f 20 31 20 4c 53 | 42 2c 20 61 6e 64 20 6e | to 1 LS|B, and n|
|00000760| 6f 77 20 75 73 65 20 74 | 68 65 20 68 69 67 68 65 |ow use t|he highe|
|00000770| 73 74 0d 09 09 09 6c 75 | 6d 69 6e 61 6e 63 65 20 |st....lu|minance |
|00000780| 67 61 69 6e 20 28 77 6f | 72 73 74 20 63 61 73 65 |gain (wo|rst case|
|00000790| 29 20 6f 76 65 72 20 74 | 68 65 20 72 65 71 75 65 |) over t|he reque|
|000007a0| 73 74 65 64 20 72 61 6e | 67 65 20 74 6f 20 74 72 |sted ran|ge to tr|
|000007b0| 61 6e 73 66 6f 72 6d 20 | 69 74 0d 09 09 09 69 6e |ansform |it....in|
|000007c0| 74 6f 20 61 20 6c 75 6d | 69 6e 61 6e 63 65 20 64 |to a lum|inance d|
|000007d0| 69 66 66 65 72 65 6e 63 | 65 20 74 6f 6c 65 72 61 |ifferenc|e tolera|
|000007e0| 6e 63 65 2e 0d 38 2f 32 | 31 2f 38 39 09 64 67 70 |nce..8/2|1/89.dgp|
|000007f0| 09 4d 61 64 65 20 6d 69 | 6e 6f 72 20 69 6d 70 72 |.Made mi|nor impr|
|00000800| 6f 76 65 6d 65 6e 74 73 | 20 69 6e 20 4c 54 6f 56 |ovements| in LToV|
|00000810| 28 29 20 74 6f 20 64 65 | 61 6c 20 77 69 74 68 20 |() to de|al with |
|00000820| 66 61 69 6c 75 72 65 20 | 74 6f 20 63 6f 6e 76 65 |failure |to conve|
|00000830| 72 67 65 20 64 75 65 20 | 74 6f 20 0d 09 09 09 67 |rge due |to ....g|
|00000840| 65 74 74 69 6e 67 20 73 | 74 75 63 6b 20 69 6e 20 |etting s|tuck in |
|00000850| 61 20 6c 6f 63 61 6c 20 | 6d 69 6e 69 6d 75 6d 20 |a local |minimum |
|00000860| 6f 66 20 74 68 65 20 71 | 75 61 72 74 69 63 2e 20 |of the q|uartic. |
|00000870| 4d 79 20 73 6f 6c 75 74 | 69 6f 6e 20 69 73 20 74 |My solut|ion is t|
|00000880| 6f 20 6e 6f 77 0d 09 09 | 09 52 45 51 55 49 52 45 |o now...|.REQUIRE|
|00000890| 20 74 68 61 74 20 4c 6d | 69 6e 20 61 6e 64 20 4c | that Lm|in and L|
|000008a0| 6d 61 78 20 62 65 20 66 | 69 6c 6c 65 64 20 69 6e |max be f|illed in|
|000008b0| 20 62 79 20 74 68 65 20 | 75 73 65 72 20 69 6e 20 | by the |user in |
|000008c0| 74 68 65 20 63 61 6c 69 | 62 72 61 74 69 6f 6e 0d |the cali|bration.|
|000008d0| 09 09 09 73 74 72 75 63 | 74 75 72 65 2e 20 49 6e |...struc|ture. In|
|000008e0| 20 70 72 61 63 74 69 63 | 65 20 74 68 69 73 20 77 | practic|e this w|
|000008f0| 69 6c 6c 20 67 75 61 72 | 61 6e 74 65 65 20 74 68 |ill guar|antee th|
|00000900| 61 74 20 74 68 65 20 6d | 69 6e 69 6d 75 6d 20 6c |at the m|inimum l|
|00000910| 75 6d 69 6e 61 6e 63 65 | 0d 09 09 09 77 69 6c 6c |uminance|....will|
|00000920| 20 6e 6f 74 20 62 65 20 | 62 65 6c 6f 77 20 74 68 | not be |below th|
|00000930| 65 20 6c 6f 63 61 6c 20 | 6d 69 6e 69 6d 75 6d 20 |e local |minimum |
|00000940| 66 6f 75 6e 64 20 61 74 | 20 74 68 65 20 62 61 73 |found at| the bas|
|00000950| 65 20 6f 66 20 74 68 65 | 20 72 69 73 69 6e 67 20 |e of the| rising |
|00000960| 63 75 72 76 65 2e 0d 09 | 09 09 4c 61 73 74 20 77 |curve...|..Last w|
|00000970| 65 65 6b 20 49 20 61 6c | 73 6f 20 63 68 61 6e 67 |eek I al|so chang|
|00000980| 65 64 20 74 68 65 20 4c | 54 6f 56 20 61 6c 67 6f |ed the L|ToV algo|
|00000990| 72 69 74 68 6d 20 73 6c | 69 67 68 74 6c 79 2c 20 |rithm sl|ightly, |
|000009a0| 74 6f 20 64 6f 20 61 20 | 62 69 73 65 63 74 69 6f |to do a |bisectio|
|000009b0| 6e 20 69 66 0d 09 09 09 | 4e 65 77 74 6f 6e 27 73 |n if....|Newton's|
|000009c0| 20 6d 65 74 68 6f 64 20 | 77 6f 75 6c 64 20 74 61 | method |would ta|
|000009d0| 6b 65 20 75 73 20 6f 75 | 74 20 6f 66 20 72 61 6e |ke us ou|t of ran|
|000009e0| 67 65 2e 0d 39 2f 37 2f | 38 39 20 64 67 70 09 46 |ge..9/7/|89 dgp.F|
|000009f0| 69 78 65 64 20 62 75 67 | 20 69 6e 20 73 6f 72 74 |ixed bug| in sort|
|00000a00| 69 6e 67 20 72 6f 75 74 | 69 6e 65 2c 20 53 6f 72 |ing rout|ine, Sor|
|00000a10| 74 28 29 2e 0d 39 2f 31 | 30 2f 38 39 20 64 67 70 |t()..9/1|0/89 dgp|
|00000a20| 09 43 6f 6d 6d 65 6e 74 | 65 64 20 6f 75 74 20 74 |.Comment|ed out t|
|00000a30| 68 65 20 70 6f 6c 79 6e | 6f 6d 69 61 6c 20 76 65 |he polyn|omial ve|
|00000a40| 72 73 69 6f 6e 73 20 6f | 66 20 56 54 6f 4c 20 61 |rsions o|f VToL a|
|00000a50| 6e 64 20 4c 54 6f 56 20 | 61 6e 64 20 72 65 70 6c |nd LToV |and repl|
|00000a60| 61 63 65 20 74 68 65 6d | 20 62 79 0d 09 09 09 6e |ace them| by....n|
|00000a70| 65 77 20 76 65 72 73 69 | 6f 6e 73 20 74 68 61 74 |ew versi|ons that|
|00000a80| 20 75 73 65 20 61 20 70 | 6f 77 65 72 20 6c 61 77 | use a p|ower law|
|00000a90| 2e 20 54 68 65 20 70 6f | 77 65 72 20 6c 61 77 20 |. The po|wer law |
|00000aa0| 69 73 20 61 20 6d 61 72 | 67 69 6e 61 6c 6c 79 20 |is a mar|ginally |
|00000ab0| 62 65 74 74 65 72 20 66 | 69 74 0d 09 09 09 74 68 |better f|it....th|
|00000ac0| 61 6e 20 61 20 36 74 68 | 20 6f 72 64 65 72 20 70 |an a 6th| order p|
|00000ad0| 6f 6c 79 6e 6f 6d 69 61 | 6c 20 28 75 73 69 6e 67 |olynomia|l (using|
|00000ae0| 20 6f 6e 6c 79 20 34 20 | 69 6e 73 74 65 61 64 20 | only 4 |instead |
|00000af0| 6f 66 20 37 20 70 61 72 | 61 6d 65 74 65 72 73 29 |of 7 par|ameters)|
|00000b00| 20 61 6e 64 20 69 74 73 | 0d 09 09 09 69 6e 76 65 | and its|....inve|
|00000b10| 72 73 65 20 63 61 6e 20 | 62 65 20 63 6f 6d 70 75 |rse can |be compu|
|00000b20| 74 65 64 20 6d 75 63 68 | 20 6d 6f 72 65 20 71 75 |ted much| more qu|
|00000b30| 69 63 6b 6c 79 2c 20 61 | 62 6f 75 74 20 30 2e 33 |ickly, a|bout 0.3|
|00000b40| 20 6d 73 20 69 6e 73 74 | 65 61 64 20 6f 66 20 32 | ms inst|ead of 2|
|00000b50| 20 6d 73 2e 0d 39 2f 31 | 31 2f 38 39 20 64 67 70 | ms..9/1|1/89 dgp|
|00000b60| 09 44 65 63 69 64 69 6e | 67 20 74 6f 20 62 65 20 |.Decidin|g to be |
|00000b70| 69 6e 64 65 63 69 73 69 | 76 65 2c 20 49 20 69 6e |indecisi|ve, I in|
|00000b80| 74 72 6f 64 75 63 65 64 | 20 61 20 63 6f 6e 64 69 |troduced| a condi|
|00000b90| 74 69 6f 6e 61 6c 20 50 | 4f 57 45 52 5f 4c 41 57 |tional P|OWER_LAW|
|00000ba0| 5f 46 49 54 0d 09 09 09 | 74 6f 20 63 6f 6e 74 72 |_FIT....|to contr|
|00000bb0| 6f 6c 20 74 68 65 20 63 | 68 6f 69 63 65 20 6f 66 |ol the c|hoice of|
|00000bc0| 20 70 6f 77 65 72 20 6c | 61 77 20 6f 72 20 70 6f | power l|aw or po|
|00000bd0| 6c 79 6e 6f 6d 69 61 6c | 20 66 69 74 20 66 6f 72 |lynomial| fit for|
|00000be0| 20 4c 54 6f 56 20 61 6e | 64 20 56 54 6f 4c 2e 0d | LToV an|d VToL..|
|00000bf0| 39 2f 31 36 2f 38 39 09 | 64 67 70 09 48 61 76 69 |9/16/89.|dgp.Havi|
|00000c00| 6e 67 20 66 69 6e 69 73 | 68 65 64 20 77 72 69 74 |ng finis|hed writ|
|00000c10| 69 6e 67 20 74 68 65 20 | 70 61 70 65 72 20 28 50 |ing the |paper (P|
|00000c20| 65 6c 6c 69 20 26 20 5a | 68 61 6e 67 2c 20 31 39 |elli & Z|hang, 19|
|00000c30| 39 31 29 20 49 20 63 61 | 6d 65 20 62 61 63 6b 20 |91) I ca|me back |
|00000c40| 74 6f 0d 09 09 09 63 68 | 61 6e 67 65 20 74 68 65 |to....ch|ange the|
|00000c50| 20 70 72 6f 67 72 61 6d | 20 74 6f 20 61 67 72 65 | program| to agre|
|00000c60| 65 20 77 69 74 68 20 77 | 68 61 74 20 49 20 77 72 |e with w|hat I wr|
|00000c70| 6f 74 65 2e 20 49 20 63 | 68 61 6e 67 65 64 20 74 |ote. I c|hanged t|
|00000c80| 68 65 20 65 71 75 69 76 | 61 6c 65 6e 74 0d 09 09 |he equiv|alent...|
|00000c90| 09 6e 75 6d 62 65 72 20 | 74 6f 6c 65 72 61 6e 63 |.number |toleranc|
|00000ca0| 65 20 74 6f 20 62 65 20 | 74 68 65 20 73 75 6d 20 |e to be |the sum |
|00000cb0| 69 6e 73 74 65 61 64 20 | 6f 66 20 74 68 65 20 6d |instead |of the m|
|00000cc0| 61 78 69 6d 75 6d 20 6f | 66 20 74 68 65 20 0d 09 |aximum o|f the ..|
|00000cd0| 09 09 76 61 72 69 61 62 | 6c 65 2d 64 61 63 20 67 |..variab|le-dac g|
|00000ce0| 61 69 6e 73 2e 0d 39 2f | 32 35 2f 38 39 20 64 67 |ains..9/|25/89 dg|
|00000cf0| 70 20 46 69 78 65 64 20 | 6d 69 6e 6f 72 20 62 75 |p Fixed |minor bu|
|00000d00| 67 20 69 6e 20 63 6f 6d | 70 75 74 61 74 69 6f 6e |g in com|putation|
|00000d10| 20 6f 66 20 74 6f 6c 65 | 72 61 6e 63 65 2e 20 4e | of tole|rance. N|
|00000d20| 6f 77 20 67 69 76 65 73 | 20 63 6f 72 72 65 63 74 |ow gives| correct|
|00000d30| 20 61 6e 73 77 65 72 20 | 65 76 65 6e 0d 09 09 09 | answer |even....|
|00000d40| 77 68 65 6e 20 74 68 65 | 20 6c 6f 77 4c 75 6d 69 |when the| lowLumi|
|00000d50| 6e 61 6e 63 65 20 6f 72 | 20 68 69 67 68 4c 75 6d |nance or| highLum|
|00000d60| 69 6e 61 6e 63 65 20 69 | 73 20 6f 75 74 20 6f 66 |inance i|s out of|
|00000d70| 20 72 61 6e 67 65 2e 0d | 31 30 2f 39 2f 38 39 20 | range..|10/9/89 |
|00000d80| 64 67 70 09 4d 61 64 65 | 20 6d 69 6e 6f 72 20 63 |dgp.Made| minor c|
|00000d90| 68 61 6e 67 65 20 73 6f | 20 74 68 61 74 20 77 68 |hange so| that wh|
|00000da0| 65 6e 20 73 6f 6d 65 20 | 6f 66 20 74 68 65 20 67 |en some |of the g|
|00000db0| 61 69 6e 5b 5d 20 61 72 | 65 20 7a 65 72 6f 20 53 |ain[] ar|e zero S|
|00000dc0| 65 74 4c 75 6d 69 6e 61 | 6e 63 65 20 77 69 6c 6c |etLumina|nce will|
|00000dd0| 0d 09 09 09 6c 6f 61 64 | 20 7a 65 72 6f 20 69 6e |....load| zero in|
|00000de0| 74 6f 20 74 68 65 20 75 | 6e 75 73 65 64 20 63 6f |to the u|nused co|
|00000df0| 6c 6f 72 53 70 65 63 20 | 61 72 72 61 79 20 65 6c |lorSpec |array el|
|00000e00| 65 6d 65 6e 74 73 2e 20 | 54 68 69 73 20 69 73 20 |ements. |This is |
|00000e10| 6f 6e 6c 79 20 61 20 63 | 6f 73 6d 65 74 69 63 0d |only a c|osmetic.|
|00000e20| 09 09 09 63 68 61 6e 67 | 65 2e 0d 31 30 2f 32 38 |...chang|e..10/28|
|00000e30| 2f 38 39 20 64 67 70 20 | 4d 61 64 65 20 6d 69 6e |/89 dgp |Made min|
|00000e40| 6f 72 20 63 68 61 6e 67 | 65 73 2e 20 49 20 64 65 |or chang|es. I de|
|00000e50| 63 6c 61 72 65 64 20 4c | 54 6f 56 50 6f 6c 79 6e |clared L|ToVPolyn|
|00000e60| 6f 6d 69 61 6c 20 61 6e | 64 20 4c 54 6f 56 50 6f |omial an|d LToVPo|
|00000e70| 77 65 72 20 61 6e 64 0d | 09 09 09 56 54 6f 4c 50 |wer and.|...VToLP|
|00000e80| 6f 6c 79 6e 6f 6d 69 61 | 6c 20 61 6e 64 20 56 54 |olynomia|l and VT|
|00000e90| 6f 4c 50 6f 77 65 72 20 | 69 6e 73 74 65 61 64 20 |oLPower |instead |
|00000ea0| 6f 66 20 68 61 76 69 6e | 67 20 61 20 63 6f 6e 64 |of havin|g a cond|
|00000eb0| 69 74 69 6f 6e 61 6c 20 | 63 6f 6d 70 69 6c 61 74 |itional |compilat|
|00000ec0| 69 6f 6e 2e 20 0d 09 09 | 09 54 68 69 73 20 6d 61 |ion. ...|.This ma|
|00000ed0| 6b 65 73 20 62 6f 74 68 | 20 66 6c 61 76 6f 72 73 |kes both| flavors|
|00000ee0| 20 6f 66 20 72 6f 75 74 | 69 6e 65 20 61 6c 77 61 | of rout|ine alwa|
|00000ef0| 79 73 20 61 76 61 69 6c | 61 62 6c 65 2e 20 49 20 |ys avail|able. I |
|00000f00| 61 6c 73 6f 20 63 68 61 | 6e 67 65 64 20 0d 09 09 |also cha|nged ...|
|00000f10| 09 4c 54 6f 56 50 6f 6c | 79 6e 6f 6d 69 61 6c 20 |.LToVPol|ynomial |
|00000f20| 74 6f 20 75 73 65 20 4c | 54 6f 56 50 6f 77 65 72 |to use L|ToVPower|
|00000f30| 20 69 6e 73 74 65 61 64 | 20 6f 66 20 4c 54 6f 56 | instead| of LToV|
|00000f40| 51 75 61 64 72 61 74 69 | 63 20 66 6f 72 20 69 74 |Quadrati|c for it|
|00000f50| 73 20 69 6e 69 74 69 61 | 6c 20 0d 09 09 09 67 75 |s initia|l ....gu|
|00000f60| 65 73 73 2e 20 54 68 65 | 20 71 75 61 64 72 61 74 |ess. The| quadrat|
|00000f70| 69 63 20 67 75 65 73 73 | 20 77 61 73 20 6f 66 74 |ic guess| was oft|
|00000f80| 65 6e 20 70 6f 6f 72 20 | 61 6e 64 20 6f 63 63 61 |en poor |and occa|
|00000f90| 73 69 6f 6e 61 6c 6c 79 | 20 6c 65 64 20 74 6f 20 |sionally| led to |
|00000fa0| 0d 09 09 09 63 6f 6e 76 | 65 72 67 65 6e 63 65 20 |....conv|ergence |
|00000fb0| 70 72 6f 62 6c 65 6d 73 | 2e 20 49 66 20 74 68 65 |problems|. If the|
|00000fc0| 20 70 6f 77 65 72 20 6c | 61 77 20 66 69 74 20 69 | power l|aw fit i|
|00000fd0| 73 20 6e 6f 74 20 61 76 | 61 69 6c 61 62 6c 65 20 |s not av|ailable |
|00000fe0| 74 68 65 6e 20 69 74 20 | 72 65 76 65 72 74 73 0d |then it |reverts.|
|00000ff0| 09 09 09 74 6f 20 75 73 | 69 6e 67 20 74 68 65 20 |...to us|ing the |
|00001000| 71 75 61 64 72 61 74 69 | 63 20 66 69 74 2e 20 49 |quadrati|c fit. I|
|00001010| 66 20 74 68 61 74 27 73 | 20 6e 6f 74 20 61 76 61 |f that's| not ava|
|00001020| 69 6c 61 62 6c 65 20 74 | 68 65 6e 20 69 74 20 72 |ilable t|hen it r|
|00001030| 65 76 65 72 74 73 20 74 | 6f 20 75 73 69 6e 67 0d |everts t|o using.|
|00001040| 09 09 09 61 20 6d 69 64 | 64 6c 65 2d 6f 66 2d 72 |...a mid|dle-of-r|
|00001050| 61 6e 67 65 20 67 75 65 | 73 73 2e 0d 31 30 2f 32 |ange gue|ss..10/2|
|00001060| 38 2f 38 39 20 64 67 70 | 20 49 20 65 6c 69 6d 69 |8/89 dgp| I elimi|
|00001070| 6e 61 74 65 64 20 74 68 | 65 20 63 6f 6d 70 69 6c |nated th|e compil|
|00001080| 65 2d 74 69 6d 65 20 66 | 6c 61 67 20 50 4f 57 45 |e-time f|lag POWE|
|00001090| 52 5f 4c 41 57 5f 46 49 | 54 20 61 6e 64 20 69 6e |R_LAW_FI|T and in|
|000010a0| 73 74 65 61 64 20 75 73 | 65 20 77 68 69 63 68 65 |stead us|e whiche|
|000010b0| 76 65 72 2c 20 0d 09 09 | 09 70 6f 6c 79 6e 6f 6d |ver, ...|.polynom|
|000010c0| 69 61 6c 20 6f 72 20 70 | 6f 77 65 72 2c 20 70 72 |ial or p|ower, pr|
|000010d0| 6f 76 69 64 65 73 20 61 | 20 62 65 74 74 65 72 20 |ovides a| better |
|000010e0| 66 69 74 2c 20 61 73 20 | 64 65 74 65 72 6d 69 6e |fit, as |determin|
|000010f0| 65 64 20 61 74 20 72 75 | 6e 20 74 69 6d 65 2e 20 |ed at ru|n time. |
|00001100| 49 20 0d 09 09 09 62 69 | 61 73 65 64 20 74 68 65 |I ....bi|ased the|
|00001110| 20 63 6f 6d 70 61 72 69 | 73 6f 6e 20 6f 66 20 72 | compari|son of r|
|00001120| 6d 73 20 65 72 72 6f 72 | 20 74 6f 20 66 61 76 6f |ms error| to favo|
|00001130| 72 20 74 68 65 20 70 6f | 77 65 72 20 6c 61 77 20 |r the po|wer law |
|00001140| 66 69 74 20 73 69 6e 63 | 65 20 69 74 20 68 61 73 |fit sinc|e it has|
|00001150| 20 0d 09 09 09 66 65 77 | 20 70 61 72 61 6d 65 74 | ....few| paramet|
|00001160| 65 72 73 20 61 6e 64 20 | 63 61 6e 20 62 65 20 69 |ers and |can be i|
|00001170| 6e 76 65 72 74 65 64 20 | 6d 75 63 68 20 6d 6f 72 |nverted |much mor|
|00001180| 65 20 71 75 69 63 6b 6c | 79 2e 20 4e 6f 74 65 3a |e quickl|y. Note:|
|00001190| 20 69 66 20 74 68 65 20 | 0d 09 09 09 70 6f 77 65 | if the |....powe|
|000011a0| 72 2c 20 70 6f 6c 79 6e | 6f 6d 69 61 6c 2c 20 6f |r, polyn|omial, o|
|000011b0| 72 20 71 75 61 64 72 61 | 74 69 63 20 66 69 74 20 |r quadra|tic fit |
|000011c0| 70 61 72 61 6d 65 74 65 | 72 73 20 61 72 65 20 6e |paramete|rs are n|
|000011d0| 6f 74 20 73 75 70 70 6c | 69 65 64 20 74 68 65 6e |ot suppl|ied then|
|000011e0| 20 74 68 65 20 0d 09 09 | 09 61 70 70 72 6f 70 72 | the ...|.appropr|
|000011f0| 69 61 74 65 20 4c 52 2e | 70 6f 77 65 72 45 72 72 |iate LR.|powerErr|
|00001200| 6f 72 2c 20 4c 52 2e 70 | 6f 6c 79 6e 6f 6d 69 61 |or, LR.p|olynomia|
|00001210| 6c 45 72 72 6f 72 2c 20 | 6f 72 20 4c 52 2e 71 75 |lError, |or LR.qu|
|00001220| 61 64 72 61 74 69 63 45 | 72 72 6f 72 20 66 69 65 |adraticE|rror fie|
|00001230| 6c 64 20 0d 09 09 09 73 | 68 6f 75 6c 64 20 62 65 |ld ....s|hould be|
|00001240| 20 73 65 74 20 74 6f 20 | 69 6e 66 69 6e 69 74 79 | set to |infinity|
|00001250| 3a 20 49 4e 46 20 6f 72 | 20 31 2e 30 2f 30 2e 30 |: INF or| 1.0/0.0|
|00001260| 2e 0d 31 32 2f 35 2f 38 | 39 09 64 67 70 09 41 64 |..12/5/8|9.dgp.Ad|
|00001270| 64 65 64 20 74 68 65 20 | 74 72 69 76 69 61 6c 20 |ded the |trivial |
|00001280| 72 6f 75 74 69 6e 65 20 | 4c 54 6f 4c 28 29 20 77 |routine |LToL() w|
|00001290| 68 69 63 68 20 65 6e 66 | 6f 72 63 65 73 20 74 68 |hich enf|orces th|
|000012a0| 65 20 62 6f 75 6e 64 73 | 20 4c 50 2d 3e 4c 4d 69 |e bounds| LP->LMi|
|000012b0| 6e 20 61 6e 64 20 0d 09 | 09 09 4c 50 2d 3e 4c 4d |n and ..|..LP->LM|
|000012c0| 61 78 2e 0d 34 2f 32 2f | 39 30 09 64 67 70 09 43 |ax..4/2/|90.dgp.C|
|000012d0| 61 70 69 74 61 6c 69 7a | 65 64 20 74 68 65 20 77 |apitaliz|ed the w|
|000012e0| 6f 72 64 20 22 54 6f 22 | 20 69 6e 20 61 6c 6c 20 |ord "To"| in all |
|000012f0| 66 75 6e 63 74 69 6f 6e | 20 6e 61 6d 65 73 2c 20 |function| names, |
|00001300| 65 2e 67 2e 20 4c 54 6f | 4c 28 29 2e 0d 34 2f 32 |e.g. LTo|L()..4/2|
|00001310| 32 2f 39 30 09 64 67 70 | 09 56 65 72 73 69 6f 6e |2/90.dgp|.Version|
|00001320| 20 31 2e 34 2e 20 4d 61 | 64 65 20 6d 69 6e 6f 72 | 1.4. Ma|de minor|
|00001330| 20 63 68 61 6e 67 65 73 | 20 74 6f 20 74 68 65 20 | changes| to the |
|00001340| 64 6f 63 75 6d 65 6e 74 | 61 74 69 6f 6e 2e 20 52 |document|ation. R|
|00001350| 65 6e 61 6d 65 64 20 4c | 54 6f 56 28 29 20 74 6f |enamed L|ToV() to|
|00001360| 0d 09 09 09 4c 54 6f 56 | 46 6f 72 6d 75 6c 61 69 |....LToV|Formulai|
|00001370| 63 28 29 2c 20 61 6e 64 | 20 69 6e 74 72 6f 64 75 |c(), and| introdu|
|00001380| 63 65 64 20 61 20 6e 65 | 77 20 4c 54 6f 56 28 29 |ced a ne|w LToV()|
|00001390| 20 74 68 61 74 20 75 73 | 65 73 20 61 20 74 61 62 | that us|es a tab|
|000013a0| 6c 65 20 74 6f 20 72 75 | 6e 20 66 61 73 74 65 72 |le to ru|n faster|
|000013b0| 2e 0d 09 09 09 4c 54 6f | 56 28 29 20 74 61 6b 65 |.....LTo|V() take|
|000013c0| 73 20 61 6e 20 61 76 65 | 72 61 67 65 20 6f 66 20 |s an ave|rage of |
|000013d0| 31 37 30 20 b5 73 2c 20 | 77 68 65 72 65 61 73 20 |170 .s, |whereas |
|000013e0| 4c 54 6f 56 46 6f 72 6d | 75 6c 61 69 63 28 29 20 |LToVForm|ulaic() |
|000013f0| 74 61 6b 65 73 0d 09 09 | 09 31 37 30 30 20 b5 73 |takes...|.1700 .s|
|00001400| 2e 20 49 20 61 6c 73 6f | 20 6e 6f 77 20 75 73 65 |. I also| now use|
|00001410| 20 74 68 65 20 6c 75 6d | 69 6e 61 6e 63 65 54 61 | the lum|inanceTa|
|00001420| 62 6c 65 2c 20 69 66 20 | 61 76 61 69 6c 61 62 6c |ble, if |availabl|
|00001430| 65 2c 20 74 6f 20 73 70 | 65 65 64 20 75 70 0d 09 |e, to sp|eed up..|
|00001440| 09 09 56 54 6f 4c 28 29 | 20 73 6c 69 67 68 74 6c |..VToL()| slightl|
|00001450| 79 2c 20 66 72 6f 6d 20 | 33 31 30 20 b5 73 20 74 |y, from |310 .s t|
|00001460| 6f 20 31 38 30 20 b5 73 | 2e 20 45 61 63 68 20 63 |o 180 .s|. Each c|
|00001470| 61 6c 6c 20 74 6f 20 53 | 65 74 4c 75 6d 69 6e 61 |all to S|etLumina|
|00001480| 6e 63 65 28 29 20 6e 6f | 77 0d 09 09 09 74 61 6b |nce() no|w....tak|
|00001490| 65 73 20 30 2e 39 20 6d | 73 20 77 68 65 72 65 61 |es 0.9 m|s wherea|
|000014a0| 73 20 69 74 20 75 73 65 | 64 20 74 6f 20 74 61 6b |s it use|d to tak|
|000014b0| 65 20 32 2e 35 20 6d 73 | 2e 20 54 68 65 20 6c 6f |e 2.5 ms|. The lo|
|000014c0| 73 73 20 69 6e 20 61 63 | 63 75 72 61 63 79 20 69 |ss in ac|curacy i|
|000014d0| 73 0d 09 09 09 6e 65 67 | 6c 69 67 69 62 6c 65 2e |s....neg|ligible.|
|000014e0| 20 54 68 65 20 69 6e 74 | 65 72 70 6f 6c 61 74 69 | The int|erpolati|
|000014f0| 6f 6e 20 65 72 72 6f 72 | 20 63 61 6e 20 62 65 20 |on error| can be |
|00001500| 72 65 64 75 63 65 64 20 | 73 74 69 6c 6c 20 66 75 |reduced |still fu|
|00001510| 72 74 68 65 72 20 62 79 | 0d 09 09 09 69 6e 63 72 |rther by|....incr|
|00001520| 65 61 73 69 6e 67 20 4c | 55 4d 49 4e 41 4e 43 45 |easing L|UMINANCE|
|00001530| 53 5f 49 4e 5f 54 41 42 | 4c 45 2e 20 45 61 63 68 |S_IN_TAB|LE. Each|
|00001540| 20 64 6f 75 62 6c 69 6e | 67 20 6f 66 20 74 68 65 | doublin|g of the|
|00001550| 20 74 61 62 6c 65 20 73 | 69 7a 65 20 71 75 61 72 | table s|ize quar|
|00001560| 74 65 72 73 20 74 68 65 | 0d 09 09 09 6d 61 78 69 |ters the|....maxi|
|00001570| 6d 75 6d 20 70 6f 73 73 | 69 62 6c 65 20 65 72 72 |mum poss|ible err|
|00001580| 6f 72 20 6f 66 20 74 68 | 65 20 69 6e 74 65 72 70 |or of th|e interp|
|00001590| 6f 6c 61 74 69 6f 6e 2e | 0d 34 2f 32 33 2f 39 30 |olation.|.4/23/90|
|000015a0| 09 64 67 70 09 41 64 64 | 65 64 20 61 20 66 65 77 |.dgp.Add|ed a few|
|000015b0| 20 6c 69 6e 65 73 20 6f | 66 20 63 6f 64 65 20 74 | lines o|f code t|
|000015c0| 6f 20 4c 54 6f 56 28 29 | 20 74 6f 20 63 68 65 63 |o LToV()| to chec|
|000015d0| 6b 20 6e 65 61 72 20 74 | 68 65 20 6c 61 73 74 20 |k near t|he last |
|000015e0| 69 6e 64 65 78 2c 20 69 | 6e 20 74 68 65 0d 09 09 |index, i|n the...|
|000015f0| 09 73 70 69 72 69 74 20 | 6f 66 20 4e 75 6d 65 72 |.spirit |of Numer|
|00001600| 69 63 61 6c 20 52 65 63 | 69 70 65 73 20 69 6e 20 |ical Rec|ipes in |
|00001610| 43 2c 20 68 75 6e 74 2e | 63 2c 20 62 65 66 6f 72 |C, hunt.|c, befor|
|00001620| 65 20 73 74 61 72 74 69 | 6e 67 20 74 68 65 20 62 |e starti|ng the b|
|00001630| 69 73 65 63 74 69 6f 6e | 0d 09 09 09 73 65 61 72 |isection|....sear|
|00001640| 63 68 2e 20 49 20 75 70 | 64 61 74 65 64 20 74 68 |ch. I up|dated th|
|00001650| 65 20 74 69 6d 65 73 20 | 69 6e 20 74 68 65 20 34 |e times |in the 4|
|00001660| 2f 32 32 2f 39 30 20 6e | 6f 74 65 20 74 6f 20 72 |/22/90 n|ote to r|
|00001670| 65 66 6c 65 63 74 20 74 | 68 65 20 6c 61 74 65 73 |eflect t|he lates|
|00001680| 74 20 74 69 6d 69 6e 67 | 0d 09 09 09 62 79 20 54 |t timing|....by T|
|00001690| 65 73 74 4c 75 6d 69 6e | 61 6e 63 65 2e 0d 37 2f |estLumin|ance..7/|
|000016a0| 32 37 2f 39 30 09 64 67 | 70 09 54 69 67 68 74 65 |27/90.dg|p.Tighte|
|000016b0| 6e 65 64 20 75 70 20 74 | 68 65 20 65 72 72 6f 72 |ned up t|he error|
|000016c0| 20 63 68 65 63 6b 69 6e | 67 20 66 6f 72 20 69 6c | checkin|g for il|
|000016d0| 6c 65 67 61 6c 20 65 6e | 74 72 69 65 73 20 69 6e |legal en|tries in|
|000016e0| 74 6f 20 74 68 65 20 63 | 6c 75 74 2e 20 49 20 68 |to the c|lut. I h|
|000016f0| 61 76 65 0d 09 09 09 74 | 68 65 20 69 6d 70 72 65 |ave....t|he impre|
|00001700| 73 73 69 6f 6e 20 74 68 | 61 74 2c 20 63 6f 6e 74 |ssion th|at, cont|
|00001710| 72 61 72 79 20 74 6f 20 | 73 70 65 63 69 66 69 63 |rary to |specific|
|00001720| 61 74 69 6f 6e 2c 20 74 | 68 65 20 41 70 70 6c 65 |ation, t|he Apple|
|00001730| 20 76 69 64 65 6f 20 64 | 72 69 76 65 72 0d 09 09 | video d|river...|
|00001740| 09 63 72 61 73 68 65 73 | 20 61 6e 64 20 63 6f 72 |.crashes| and cor|
|00001750| 72 75 70 74 73 20 69 74 | 73 65 6c 66 20 69 66 20 |rupts it|self if |
|00001760| 67 69 76 65 6e 20 61 6e | 20 6f 75 74 2d 6f 66 2d |given an| out-of-|
|00001770| 72 61 6e 67 65 20 65 6e | 74 72 79 20 76 61 6c 75 |range en|try valu|
|00001780| 65 20 69 6e 20 61 0d 09 | 09 09 73 65 74 45 6e 74 |e in a..|..setEnt|
|00001790| 72 79 20 43 6f 6e 74 72 | 6f 6c 20 63 61 6c 6c 2e |ry Contr|ol call.|
|000017a0| 0d 39 2f 31 38 2f 39 30 | 09 64 67 70 09 43 68 61 |.9/18/90|.dgp.Cha|
|000017b0| 6e 67 65 64 20 61 6c 6c | 20 69 6e 73 74 61 6e 63 |nged all| instanc|
|000017c0| 65 73 20 6f 66 20 22 76 | 22 20 74 6f 20 22 56 22 |es of "v|" to "V"|
|000017d0| 2e 20 54 68 65 20 66 69 | 6e 61 6c 20 76 65 72 73 |. The fi|nal vers|
|000017e0| 69 6f 6e 20 6f 66 20 74 | 68 65 20 50 65 6c 6c 69 |ion of t|he Pelli|
|000017f0| 0d 09 09 09 26 20 5a 68 | 61 6e 67 20 28 31 39 39 |....& Zh|ang (199|
|00001800| 31 29 20 70 61 70 65 72 | 20 72 65 66 65 72 73 20 |1) paper| refers |
|00001810| 74 6f 20 74 68 65 20 6e | 6f 6d 69 6e 61 6c 20 76 |to the n|ominal v|
|00001820| 6f 6c 74 61 67 65 20 76 | 3b 20 74 68 69 73 20 66 |oltage v|; this f|
|00001830| 69 6c 65 0d 09 09 09 6e | 6f 77 20 72 65 66 65 72 |ile....n|ow refer|
|00001840| 73 20 74 6f 20 74 68 65 | 20 22 65 71 75 69 76 61 |s to the| "equiva|
|00001850| 6c 65 6e 74 20 6e 75 6d | 62 65 72 22 20 56 3b 20 |lent num|ber" V; |
|00001860| 74 68 65 79 20 61 72 65 | 20 72 65 6c 61 74 65 64 |they are| related|
|00001870| 20 62 79 20 56 3d 32 35 | 35 2a 76 2e 0d 39 2f 32 | by V=25|5*v..9/2|
|00001880| 34 2f 39 30 09 64 67 70 | 09 55 70 64 61 74 65 64 |4/90.dgp|.Updated|
|00001890| 20 74 68 65 20 64 6f 63 | 75 6d 65 6e 74 61 74 69 | the doc|umentati|
|000018a0| 6f 6e 20 74 6f 20 63 6f | 72 72 65 73 70 6f 6e 64 |on to co|rrespond|
|000018b0| 20 6d 6f 72 65 20 63 6c | 6f 73 65 6c 79 20 74 6f | more cl|osely to|
|000018c0| 20 74 68 65 20 28 68 6f | 70 65 66 75 6c 6c 79 29 | the (ho|pefully)|
|000018d0| 0d 09 09 09 66 69 6e 61 | 6c 20 76 65 72 73 69 6f |....fina|l versio|
|000018e0| 6e 20 6f 66 20 74 68 65 | 20 50 65 6c 6c 69 20 26 |n of the| Pelli &|
|000018f0| 20 5a 68 61 6e 67 20 28 | 31 39 39 31 29 20 70 61 | Zhang (|1991) pa|
|00001900| 70 65 72 2e 0d 31 30 2f | 32 39 2f 39 30 20 64 67 |per..10/|29/90 dg|
|00001910| 70 20 44 6f 75 62 6c 65 | 64 20 73 70 65 65 64 20 |p Double|d speed |
|00001920| 6f 66 20 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 28 |of SetLu|minance(|
|00001930| 29 2e 20 4e 6f 77 20 53 | 65 74 4c 75 6d 69 6e 61 |). Now S|etLumina|
|00001940| 6e 63 65 28 29 20 74 61 | 6b 65 73 20 31 33 33 20 |nce() ta|kes 133 |
|00001950| 6d 73 20 74 6f 0d 09 09 | 09 64 6f 20 61 20 63 6f |ms to...|.do a co|
|00001960| 6d 70 6c 65 74 65 20 63 | 6c 75 74 20 66 6f 72 20 |mplete c|lut for |
|00001970| 61 20 73 6d 61 6c 6c 20 | 6e 65 77 20 6c 75 6d 69 |a small |new lumi|
|00001980| 6e 61 6e 63 65 20 72 61 | 6e 67 65 2c 20 61 6e 64 |nance ra|nge, and|
|00001990| 20 74 61 6b 65 73 20 31 | 38 38 20 6d 73 20 66 6f | takes 1|88 ms fo|
|000019a0| 72 20 61 0d 09 09 09 6c | 61 72 67 65 20 6e 65 77 |r a....l|arge new|
|000019b0| 20 72 61 6e 67 65 2e 20 | 54 68 69 73 20 72 65 71 | range. |This req|
|000019c0| 75 69 72 65 64 20 6d 69 | 6e 6f 72 20 63 68 61 6e |uired mi|nor chan|
|000019d0| 67 65 73 20 74 6f 20 53 | 65 74 4c 75 6d 69 6e 61 |ges to S|etLumina|
|000019e0| 6e 63 65 52 61 6e 67 65 | 28 29 20 26 20 4c 54 6f |nceRange|() & LTo|
|000019f0| 56 28 29 2e 0d 09 09 09 | 43 68 61 6e 67 65 64 20 |V().....|Changed |
|00001a00| 61 6c 6c 20 66 75 6e 63 | 74 69 6f 6e 20 68 65 61 |all func|tion hea|
|00001a10| 64 65 72 73 20 74 6f 20 | 41 4e 53 49 20 70 72 6f |ders to |ANSI pro|
|00001a20| 74 6f 74 79 70 65 20 73 | 74 79 6c 65 2e 0d 31 30 |totype s|tyle..10|
|00001a30| 2f 33 30 2f 39 30 20 64 | 67 70 20 52 65 70 6c 61 |/30/90 d|gp Repla|
|00001a40| 63 65 64 20 70 68 72 61 | 73 65 20 22 63 6c 75 74 |ced phra|se "clut|
|00001a50| 20 76 61 6c 75 65 22 20 | 62 79 20 22 6e 6f 6d 69 | value" |by "nomi|
|00001a60| 6e 61 6c 20 76 6f 6c 74 | 61 67 65 22 2c 20 66 6f |nal volt|age", fo|
|00001a70| 72 20 63 6f 6e 73 69 73 | 74 65 6e 63 79 20 77 69 |r consis|tency wi|
|00001a80| 74 68 0d 09 09 09 50 65 | 6c 6c 69 20 26 20 5a 68 |th....Pe|lli & Zh|
|00001a90| 61 6e 67 20 28 31 39 39 | 31 29 2e 0d 09 09 09 49 |ang (199|1).....I|
|00001aa0| 6e 74 72 6f 64 75 63 65 | 64 20 6e 65 77 20 66 69 |ntroduce|d new fi|
|00001ab0| 78 65 64 20 66 72 61 63 | 74 69 6f 6e 20 64 61 74 |xed frac|tion dat|
|00001ac0| 61 20 74 79 70 65 20 63 | 61 6c 6c 65 64 20 22 4d |a type c|alled "M|
|00001ad0| 69 6c 6c 69 22 2c 20 64 | 65 66 69 6e 65 64 20 69 |illi", d|efined i|
|00001ae0| 6e 20 4d 69 6c 6c 69 2e | 68 2e 0d 09 09 09 42 79 |n Milli.|h.....By|
|00001af0| 20 6a 75 64 69 63 69 6f | 75 73 20 72 65 70 6c 61 | judicio|us repla|
|00001b00| 63 65 6d 65 6e 74 20 6f | 66 20 64 6f 75 62 6c 65 |cement o|f double|
|00001b10| 20 62 79 20 4d 69 6c 6c | 69 2c 20 70 61 72 74 69 | by Mill|i, parti|
|00001b20| 63 75 6c 61 72 6c 79 20 | 69 6e 20 74 68 65 20 6c |cularly |in the l|
|00001b30| 75 6d 69 6e 61 6e 63 65 | 0d 09 09 09 74 61 62 6c |uminance|....tabl|
|00001b40| 65 2c 20 49 20 68 61 76 | 65 20 69 6e 63 72 65 61 |e, I hav|e increa|
|00001b50| 73 65 64 20 74 68 65 20 | 73 70 65 65 64 20 6f 66 |sed the |speed of|
|00001b60| 20 53 65 74 4c 75 6d 69 | 6e 61 6e 63 65 20 62 79 | SetLumi|nance by|
|00001b70| 20 61 20 66 61 63 74 6f | 72 20 6f 66 20 74 68 72 | a facto|r of thr|
|00001b80| 65 65 2e 0d 09 09 09 41 | 20 4d 61 63 20 49 49 20 |ee.....A| Mac II |
|00001b90| 6e 6f 77 20 74 61 6b 65 | 73 20 6f 6e 6c 79 20 34 |now take|s only 4|
|00001ba0| 32 20 74 6f 20 35 30 20 | 6d 73 20 74 6f 20 62 75 |2 to 50 |ms to bu|
|00001bb0| 69 6c 64 20 61 20 77 68 | 6f 6c 65 20 63 6c 75 74 |ild a wh|ole clut|
|00001bc0| 2e 20 54 68 69 73 20 6e | 65 77 20 66 65 61 74 75 |. This n|ew featu|
|00001bd0| 72 65 0d 09 09 09 69 73 | 20 65 6e 61 62 6c 65 64 |re....is| enabled|
|00001be0| 20 62 79 20 73 65 74 74 | 69 6e 67 20 46 41 53 54 | by sett|ing FAST|
|00001bf0| 5f 4c 55 4d 49 4e 41 4e | 43 45 20 74 6f 20 31 20 |_LUMINAN|CE to 1 |
|00001c00| 69 6e 20 4c 75 6d 69 6e | 61 6e 63 65 2e 68 2e 20 |in Lumin|ance.h. |
|00001c10| 54 68 65 72 65 20 69 73 | 20 61 20 73 6c 69 67 68 |There is| a sligh|
|00001c20| 74 0d 09 09 09 69 6e 63 | 72 65 61 73 65 20 69 6e |t....inc|rease in|
|00001c30| 20 74 68 65 20 6c 75 6d | 69 6e 61 6e 63 65 20 74 | the lum|inance t|
|00001c40| 6f 6c 65 72 61 6e 63 65 | 2e 0d 31 30 2f 33 31 2f |olerance|..10/31/|
|00001c50| 39 30 20 64 67 70 20 4d | 6f 72 65 20 66 69 6e 65 |90 dgp M|ore fine|
|00001c60| 20 74 75 6e 69 6e 67 2e | 20 4e 6f 77 20 74 61 6b | tuning.| Now tak|
|00001c70| 65 73 20 33 31 20 74 6f | 20 34 34 20 6d 73 20 74 |es 31 to| 44 ms t|
|00001c80| 6f 20 62 75 69 6c 64 20 | 61 20 77 68 6f 6c 65 20 |o build |a whole |
|00001c90| 63 6c 75 74 2e 20 49 6e | 74 72 6f 64 75 63 65 64 |clut. In|troduced|
|00001ca0| 0d 09 09 09 63 6f 6e 64 | 69 74 69 6f 6e 61 6c 20 |....cond|itional |
|00001cb0| 46 41 53 54 5f 4c 55 4d | 49 4e 41 4e 43 45 20 69 |FAST_LUM|INANCE i|
|00001cc0| 6e 20 4c 75 6d 69 6e 61 | 6e 63 65 2e 68 20 74 68 |n Lumina|nce.h th|
|00001cd0| 61 74 20 63 61 75 73 65 | 73 20 74 68 65 20 73 61 |at cause|s the sa|
|00001ce0| 6d 65 20 63 6f 64 65 20 | 74 6f 0d 09 09 09 62 65 |me code |to....be|
|00001cf0| 20 63 6f 6d 70 69 6c 65 | 64 20 77 69 74 68 20 65 | compile|d with e|
|00001d00| 69 74 68 65 72 20 4d 69 | 6c 6c 69 20 6f 72 20 64 |ither Mi|lli or d|
|00001d10| 6f 75 62 6c 65 20 76 61 | 72 69 61 62 6c 65 73 2e |ouble va|riables.|
|00001d20| 20 54 68 65 20 5f 53 65 | 74 4c 75 6d 69 6e 61 6e | The _Se|tLuminan|
|00001d30| 63 65 28 29 0d 09 09 09 | 72 6f 75 74 69 6e 65 20 |ce()....|routine |
|00001d40| 69 73 20 6e 6f 77 20 71 | 75 69 74 65 20 70 6f 6c |is now q|uite pol|
|00001d50| 69 73 68 65 64 2c 20 61 | 6e 64 20 72 75 6e 73 20 |ished, a|nd runs |
|00001d60| 66 61 73 74 2e 20 41 6c | 6c 20 76 61 72 69 61 62 |fast. Al|l variab|
|00001d70| 6c 65 73 20 61 6e 64 20 | 72 6f 75 74 69 6e 65 73 |les and |routines|
|00001d80| 0d 09 09 09 77 68 6f 73 | 65 20 6e 61 6d 65 73 20 |....whos|e names |
|00001d90| 62 65 67 69 6e 20 77 69 | 74 68 20 75 6e 64 65 72 |begin wi|th under|
|00001da0| 73 63 6f 72 65 20 5f 20 | 61 72 65 20 77 72 69 74 |score _ |are writ|
|00001db0| 74 65 6e 20 68 65 72 65 | 20 77 69 74 68 20 74 79 |ten here| with ty|
|00001dc0| 70 65 20 4d 69 6c 6c 69 | 2c 20 62 75 74 0d 09 09 |pe Milli|, but...|
|00001dd0| 09 69 66 20 46 41 53 54 | 5f 4c 55 4d 49 4e 41 4e |.if FAST|_LUMINAN|
|00001de0| 43 45 20 69 73 20 66 61 | 6c 73 65 20 74 68 65 6e |CE is fa|lse then|
|00001df0| 20 74 68 69 73 20 74 79 | 70 65 20 69 73 20 72 65 | this ty|pe is re|
|00001e00| 64 65 66 69 6e 65 64 20 | 28 69 6e 20 74 68 69 73 |defined |(in this|
|00001e10| 20 66 69 6c 65 20 6f 6e | 6c 79 29 0d 09 09 09 61 | file on|ly)....a|
|00001e20| 73 20 64 6f 75 62 6c 65 | 2c 20 61 6e 64 20 61 6c |s double|, and al|
|00001e30| 6c 20 74 68 65 20 4d 69 | 6c 6c 69 20 6d 61 63 72 |l the Mi|lli macr|
|00001e40| 6f 73 20 61 72 65 20 72 | 65 64 65 66 69 6e 65 64 |os are r|edefined|
|00001e50| 20 74 6f 20 62 65 20 61 | 70 70 72 6f 70 72 69 61 | to be a|ppropria|
|00001e60| 74 65 20 66 6f 72 0d 09 | 09 09 61 20 64 6f 75 62 |te for..|..a doub|
|00001e70| 6c 65 2e 20 53 6f 20 62 | 65 61 72 20 69 6e 20 6d |le. So b|ear in m|
|00001e80| 69 6e 64 20 74 68 61 74 | 20 74 68 69 6e 67 73 20 |ind that| things |
|00001e90| 62 65 67 69 6e 6e 69 6e | 67 20 77 69 74 68 20 75 |beginnin|g with u|
|00001ea0| 6e 64 65 72 73 63 6f 72 | 65 20 61 72 65 20 6f 66 |nderscor|e are of|
|00001eb0| 0d 09 09 09 75 6e 6b 6e | 6f 77 6e 20 74 79 70 65 |....unkn|own type|
|00001ec0| 2e 20 54 68 65 20 76 69 | 72 74 75 65 20 6f 66 20 |. The vi|rtue of |
|00001ed0| 62 65 69 6e 67 20 61 62 | 6c 65 20 74 6f 20 72 75 |being ab|le to ru|
|00001ee0| 6e 20 74 68 65 20 73 61 | 6d 65 20 63 6f 64 65 20 |n the sa|me code |
|00001ef0| 77 69 74 68 20 4d 69 6c | 6c 69 20 6f 72 0d 09 09 |with Mil|li or...|
|00001f00| 09 64 6f 75 62 6c 65 20 | 63 6f 6d 70 75 74 61 74 |.double |computat|
|00001f10| 69 6f 6e 73 20 69 73 20 | 74 68 61 74 20 69 66 20 |ions is |that if |
|00001f20| 79 6f 75 20 73 75 73 70 | 65 63 74 20 61 6e 20 65 |you susp|ect an e|
|00001f30| 72 72 6f 72 20 69 6e 20 | 74 68 65 20 28 68 6f 6d |rror in |the (hom|
|00001f40| 65 6d 61 64 65 29 0d 09 | 09 09 4d 69 6c 6c 69 20 |emade)..|..Milli |
|00001f50| 61 72 69 74 68 6d 65 74 | 69 63 2c 20 79 6f 75 20 |arithmet|ic, you |
|00001f60| 63 61 6e 20 74 72 79 20 | 6f 75 74 20 64 6f 75 62 |can try |out doub|
|00001f70| 6c 65 20 61 72 69 74 68 | 6d 65 74 69 63 20 73 69 |le arith|metic si|
|00001f80| 6d 70 6c 79 20 62 79 20 | 73 65 74 74 69 6e 67 0d |mply by |setting.|
|00001f90| 09 09 09 46 41 53 54 5f | 4c 55 4d 49 4e 41 4e 43 |...FAST_|LUMINANC|
|00001fa0| 45 20 74 6f 20 30 20 61 | 6e 64 20 72 65 63 6f 6d |E to 0 a|nd recom|
|00001fb0| 70 69 6c 69 6e 67 2e 0d | 09 09 09 49 6e 20 74 68 |piling..|...In th|
|00001fc0| 65 20 69 6e 74 65 72 65 | 73 74 20 6f 66 20 73 70 |e intere|st of sp|
|00001fd0| 65 65 64 20 49 20 68 61 | 76 65 20 73 74 72 65 61 |eed I ha|ve strea|
|00001fe0| 6d 6c 69 6e 65 64 20 74 | 68 65 20 74 6f 6c 65 72 |mlined t|he toler|
|00001ff0| 61 6e 63 65 0d 09 09 09 | 63 6f 6d 70 75 74 61 74 |ance....|computat|
|00002000| 69 6f 6e 2e 20 54 68 65 | 20 6e 65 77 20 74 6f 6c |ion. The| new tol|
|00002010| 65 72 61 6e 63 65 73 20 | 61 72 65 20 70 72 6f 62 |erances |are prob|
|00002020| 61 62 6c 79 20 61 73 20 | 67 6f 6f 64 20 61 73 20 |ably as |good as |
|00002030| 74 68 65 20 6f 6c 64 20 | 6f 6e 65 73 2e 0d 31 31 |the old |ones..11|
|00002040| 2f 32 2f 39 30 20 64 67 | 70 20 41 64 64 65 64 20 |/2/90 dg|p Added |
|00002050| 5f 53 65 74 4c 75 6d 69 | 6e 61 6e 63 65 73 28 29 |_SetLumi|nances()|
|00002060| 20 73 75 62 72 6f 75 74 | 69 6e 65 20 74 68 61 74 | subrout|ine that|
|00002070| 20 73 75 62 73 74 69 74 | 75 74 65 73 20 6c 69 6e | substit|utes lin|
|00002080| 65 61 72 20 69 6e 74 65 | 72 70 6f 6c 61 74 69 6f |ear inte|rpolatio|
|00002090| 6e 0d 09 09 09 66 6f 72 | 20 6d 6f 73 74 20 6f 66 |n....for| most of|
|000020a0| 20 74 68 65 20 63 61 6c | 6c 73 20 74 6f 20 5f 4c | the cal|ls to _L|
|000020b0| 54 6f 56 28 29 2e 20 54 | 68 69 73 20 68 61 73 20 |ToV(). T|his has |
|000020c0| 67 72 65 61 74 6c 79 20 | 73 70 65 65 64 65 64 20 |greatly |speeded |
|000020d0| 75 70 0d 09 09 09 53 65 | 74 4c 75 6d 69 6e 61 6e |up....Se|tLuminan|
|000020e0| 63 65 73 41 6e 64 52 61 | 6e 67 65 28 29 2c 20 77 |cesAndRa|nge(), w|
|000020f0| 69 74 68 20 6d 69 6e 6f | 72 20 6c 6f 73 73 20 6f |ith mino|r loss o|
|00002100| 66 20 61 63 63 75 72 61 | 63 79 2e 20 41 20 63 6f |f accura|cy. A co|
|00002110| 6d 70 6c 65 74 65 20 63 | 6c 75 74 20 6e 6f 77 0d |mplete c|lut now.|
|00002120| 09 09 09 74 61 6b 65 73 | 20 39 20 74 6f 20 33 31 |...takes| 9 to 31|
|00002130| 20 6d 73 2e 20 45 76 65 | 6e 20 61 20 4d 61 63 20 | ms. Eve|n a Mac |
|00002140| 49 49 20 63 61 6e 20 6e | 6f 77 20 63 6f 6d 70 75 |II can n|ow compu|
|00002150| 74 65 20 6c 6f 77 2d 63 | 6f 6e 74 72 61 73 74 20 |te low-c|ontrast |
|00002160| 63 6c 75 74 73 0d 09 09 | 09 6f 6e 20 74 68 65 20 |cluts...|.on the |
|00002170| 66 6c 79 2c 20 62 65 74 | 77 65 65 6e 20 66 72 61 |fly, bet|ween fra|
|00002180| 6d 65 73 2e 20 28 54 68 | 65 20 75 73 65 72 20 6d |mes. (Th|e user m|
|00002190| 61 79 20 77 69 73 68 20 | 74 6f 20 6f 70 74 69 6d |ay wish |to optim|
|000021a0| 69 7a 65 20 74 68 65 20 | 73 70 65 65 64 2d 0d 09 |ize the |speed-..|
|000021b0| 09 09 61 63 63 75 72 61 | 63 79 20 74 72 61 64 65 |..accura|cy trade|
|000021c0| 2d 6f 66 66 20 63 6f 6e | 74 72 6f 6c 6c 65 64 20 |-off con|trolled |
|000021d0| 62 79 20 74 68 65 20 4c | 49 4e 45 41 52 5f 56 5f |by the L|INEAR_V_|
|000021e0| 44 4f 4d 41 49 4e 20 70 | 61 72 61 6d 65 74 65 72 |DOMAIN p|arameter|
|000021f0| 2c 20 77 68 69 63 68 0d | 09 09 09 64 65 74 65 72 |, which.|...deter|
|00002200| 6d 69 6e 65 73 20 74 68 | 65 20 6d 61 78 69 6d 75 |mines th|e maximu|
|00002210| 6d 20 77 69 64 74 68 20 | 6f 66 20 74 68 65 20 69 |m width |of the i|
|00002220| 6e 74 65 72 70 6f 6c 61 | 74 69 6f 6e 20 69 6e 74 |nterpola|tion int|
|00002230| 65 72 76 61 6c 2e 29 0d | 31 31 2f 36 2f 39 30 20 |erval.).|11/6/90 |
|00002240| 64 67 70 20 52 65 70 6c | 61 63 65 64 20 4d 69 6c |dgp Repl|aced Mil|
|00002250| 6c 69 20 62 79 20 46 49 | 58 45 44 2c 20 77 68 69 |li by FI|XED, whi|
|00002260| 63 68 20 63 61 6e 20 62 | 65 20 63 6f 6d 70 69 6c |ch can b|e compil|
|00002270| 65 64 20 61 73 20 65 69 | 74 68 65 72 20 64 6f 75 |ed as ei|ther dou|
|00002280| 62 6c 65 20 6f 72 20 46 | 69 78 65 64 2e 0d 09 09 |ble or F|ixed....|
|00002290| 09 54 68 65 20 46 69 78 | 65 64 20 6d 61 74 68 20 |.The Fix|ed math |
|000022a0| 69 73 20 73 75 66 66 69 | 63 69 65 6e 74 6c 79 20 |is suffi|ciently |
|000022b0| 70 72 65 63 69 73 65 20 | 61 73 20 74 6f 20 67 69 |precise |as to gi|
|000022c0| 76 65 20 74 68 65 20 73 | 61 6d 65 20 44 41 43 20 |ve the s|ame DAC |
|000022d0| 76 61 6c 75 65 73 20 61 | 73 0d 09 09 09 64 6f 75 |values a|s....dou|
|000022e0| 62 6c 65 20 6d 61 74 68 | 2e 0d 09 09 09 4e 6f 77 |ble math|.....Now|
|000022f0| 20 66 69 67 75 72 65 20 | 6f 75 74 20 6f 70 74 69 | figure |out opti|
|00002300| 6d 61 6c 20 62 69 74 20 | 73 68 69 66 74 20 4c 54 |mal bit |shift LT|
|00002310| 2d 3e 4c 2e 4c 53 68 69 | 66 74 20 74 6f 20 70 72 |->L.LShi|ft to pr|
|00002320| 65 73 65 72 76 65 20 61 | 73 20 6d 75 63 68 20 72 |eserve a|s much r|
|00002330| 65 73 6f 6c 75 74 69 6f | 6e 0d 09 09 09 61 73 20 |esolutio|n....as |
|00002340| 70 6f 73 73 69 62 6c 65 | 20 77 68 65 6e 20 69 6e |possible| when in|
|00002350| 74 65 72 70 6f 6c 61 74 | 69 6e 67 20 69 6e 20 5f |terpolat|ing in _|
|00002360| 4c 54 6f 56 28 29 2e 20 | 0d 09 09 09 41 20 63 6f |LToV(). |....A co|
|00002370| 6d 70 6c 65 74 65 20 63 | 6c 75 74 20 6e 6f 77 20 |mplete c|lut now |
|00002380| 74 61 6b 65 73 20 38 20 | 74 6f 20 33 30 20 6d 73 |takes 8 |to 30 ms|
|00002390| 2e 20 46 6f 72 20 74 68 | 72 65 73 68 6f 6c 64 20 |. For th|reshold |
|000023a0| 73 74 69 6d 75 6c 69 20 | 74 68 65 20 61 76 65 72 |stimuli |the aver|
|000023b0| 61 67 65 0d 09 09 09 74 | 69 6d 65 20 77 69 6c 6c |age....t|ime will|
|000023c0| 20 75 73 75 61 6c 6c 79 | 20 62 65 20 6c 65 73 73 | usually| be less|
|000023d0| 20 74 68 61 6e 20 31 35 | 20 6d 73 2e 0d 31 31 2f | than 15| ms..11/|
|000023e0| 38 2f 39 30 20 64 67 70 | 09 45 6c 69 6d 69 6e 61 |8/90 dgp|.Elimina|
|000023f0| 74 65 64 20 67 61 6d 6d | 61 20 73 6c 6f 70 65 20 |ted gamm|a slope |
|00002400| 74 61 62 6c 65 20 73 69 | 6e 63 65 20 74 68 65 20 |table si|nce the |
|00002410| 73 70 65 65 64 2d 75 70 | 20 69 74 20 6f 66 66 65 |speed-up| it offe|
|00002420| 72 65 64 20 77 61 73 20 | 74 6f 6f 20 73 6d 61 6c |red was |too smal|
|00002430| 6c 0d 09 09 09 74 6f 20 | 6d 65 61 73 75 72 65 2e |l....to |measure.|
|00002440| 20 54 69 64 69 65 64 20 | 75 70 20 74 68 65 20 63 | Tidied |up the c|
|00002450| 6f 6d 70 75 74 61 74 69 | 6f 6e 20 6f 66 20 4c 53 |omputati|on of LS|
|00002460| 68 69 66 74 2e 0d 38 2f | 32 34 2f 39 31 09 64 67 |hift..8/|24/91.dg|
|00002470| 70 09 4d 61 64 65 20 63 | 6f 6d 70 61 74 69 62 6c |p.Made c|ompatibl|
|00002480| 65 20 77 69 74 68 20 54 | 48 49 4e 4b 20 43 20 35 |e with T|HINK C 5|
|00002490| 2e 30 2e 0d 31 32 2f 31 | 37 2f 39 31 20 64 67 70 |.0..12/1|7/91 dgp|
|000024a0| 20 41 64 64 65 64 20 6e | 65 77 20 72 6f 75 74 69 | Added n|ew routi|
|000024b0| 6e 65 73 3a 20 49 6e 63 | 72 65 6d 65 6e 74 4c 75 |nes: Inc|rementLu|
|000024c0| 6d 69 6e 61 6e 63 65 28 | 29 20 61 6e 64 20 47 65 |minance(|) and Ge|
|000024d0| 74 56 28 29 2e 0d 09 09 | 09 54 68 65 20 66 6f 72 |tV()....|.The for|
|000024e0| 6d 65 72 20 69 73 20 75 | 73 65 64 20 74 6f 20 6f |mer is u|sed to o|
|000024f0| 62 74 61 69 6e 20 74 68 | 65 20 6c 6f 77 65 73 74 |btain th|e lowest|
|00002500| 20 70 6f 73 73 69 62 6c | 65 20 63 6f 6e 74 72 61 | possibl|e contra|
|00002510| 73 74 2e 20 4f 6e 20 61 | 20 6c 6f 67 20 63 6f 6e |st. On a| log con|
|00002520| 74 72 61 73 74 0d 09 09 | 09 73 63 61 6c 65 2c 20 |trast...|.scale, |
|00002530| 6d 69 6e 75 73 20 69 6e | 66 69 6e 69 74 79 20 28 |minus in|finity (|
|00002540| 7a 65 72 6f 20 63 6f 6e | 74 72 61 73 74 29 20 69 |zero con|trast) i|
|00002550| 73 20 61 20 70 6f 6f 72 | 20 61 70 70 72 6f 78 69 |s a poor| approxi|
|00002560| 6d 61 74 69 6f 6e 20 74 | 6f 20 65 76 65 6e 0d 09 |mation t|o even..|
|00002570| 09 09 61 20 73 6d 61 6c | 6c 20 6c 6f 67 20 63 6f |..a smal|l log co|
|00002580| 6e 74 72 61 73 74 2e 0d | 33 2f 31 31 2f 39 32 09 |ntrast..|3/11/92.|
|00002590| 64 67 70 09 4d 69 6e 6f | 72 20 65 64 69 74 69 6e |dgp.Mino|r editin|
|000025a0| 67 20 6f 66 20 63 6f 6d | 6d 65 6e 74 73 2e 0d 31 |g of com|ments..1|
|000025b0| 32 2f 32 2f 39 32 20 64 | 67 70 20 46 69 78 65 64 |2/2/92 d|gp Fixed|
|000025c0| 20 6d 69 6e 6f 72 20 62 | 75 67 20 69 6e 20 53 65 | minor b|ug in Se|
|000025d0| 74 4c 75 6d 69 6e 61 6e | 63 65 52 61 6e 67 65 28 |tLuminan|ceRange(|
|000025e0| 29 20 72 65 70 6f 72 74 | 65 64 20 62 79 20 57 65 |) report|ed by We|
|000025f0| 69 20 58 69 65 20 61 6e | 64 20 4b 65 6e 20 41 6c |i Xie an|d Ken Al|
|00002600| 65 78 61 6e 64 65 72 0d | 09 09 09 74 68 61 74 20 |exander.|...that |
|00002610| 63 6f 75 6c 64 20 63 61 | 75 73 65 20 74 68 65 20 |could ca|use the |
|00002620| 54 48 49 4e 4b 20 43 20 | 44 65 62 75 67 67 65 72 |THINK C |Debugger|
|00002630| 20 74 6f 20 72 65 70 6f | 72 74 20 61 6e 20 65 72 | to repo|rt an er|
|00002640| 72 6f 72 20 77 68 65 6e | 20 61 6e 20 0d 09 09 09 |ror when| an ....|
|00002650| 75 6e 69 6e 69 74 69 61 | 6c 69 7a 65 64 20 64 6f |uninitia|lized do|
|00002660| 75 62 6c 65 20 56 5b 5d | 20 77 61 73 20 63 6f 6e |uble V[]| was con|
|00002670| 76 65 72 74 65 64 20 74 | 6f 20 61 6e 20 69 6e 74 |verted t|o an int|
|00002680| 2e 20 54 68 65 20 76 61 | 6c 75 65 20 77 61 73 20 |. The va|lue was |
|00002690| 6e 6f 74 20 75 73 65 64 | 20 0d 09 09 09 66 6f 72 |not used| ....for|
|000026a0| 20 61 6e 79 74 68 69 6e | 67 2c 20 73 6f 20 74 68 | anythin|g, so th|
|000026b0| 69 73 20 77 61 73 20 69 | 6e 6e 6f 63 75 6f 75 73 |is was i|nnocuous|
|000026c0| 2e 0d 31 32 2f 31 37 2f | 39 32 20 64 67 70 20 31 |..12/17/|92 dgp 1|
|000026d0| 2e 39 34 20 42 65 67 61 | 6e 20 65 6e 68 61 6e 63 |.94 Bega|n enhanc|
|000026e0| 65 6d 65 6e 74 20 74 6f | 20 61 6c 6c 6f 77 20 61 |ement to| allow a|
|000026f0| 6e 79 20 64 61 63 53 69 | 7a 65 2c 20 6e 6f 74 20 |ny dacSi|ze, not |
|00002700| 6a 75 73 74 20 38 2d 62 | 69 74 20 64 61 63 73 2e |just 8-b|it dacs.|
|00002710| 20 49 20 68 61 76 65 0d | 09 09 09 63 6f 6e 66 69 | I have.|...confi|
|00002720| 72 6d 65 64 20 74 68 61 | 74 20 65 76 65 72 79 74 |rmed tha|t everyt|
|00002730| 68 69 6e 67 20 73 74 69 | 6c 6c 20 77 6f 72 6b 73 |hing sti|ll works|
|00002740| 20 66 69 6e 65 20 77 69 | 74 68 20 38 2d 62 69 74 | fine wi|th 8-bit|
|00002750| 20 64 61 63 73 2c 20 62 | 75 74 20 49 20 64 6f 6e | dacs, b|ut I don|
|00002760| 27 74 0d 09 09 09 68 61 | 76 65 20 61 20 39 2d 62 |'t....ha|ve a 9-b|
|00002770| 69 74 20 64 61 63 20 76 | 69 64 65 6f 20 63 61 72 |it dac v|ideo car|
|00002780| 64 20 74 6f 20 74 65 73 | 74 20 69 74 20 61 6e 79 |d to tes|t it any|
|00002790| 20 66 75 72 74 68 65 72 | 2e 20 a5 43 41 55 54 49 | further|. .CAUTI|
|000027a0| 4f 4e 3a 20 74 68 69 73 | 20 70 72 6f 62 61 62 6c |ON: this| probabl|
|000027b0| 79 0d 09 09 09 64 6f 65 | 73 20 6e 6f 74 20 79 65 |y....doe|s not ye|
|000027c0| 74 20 77 6f 72 6b 20 63 | 6f 72 72 65 63 74 6c 79 |t work c|orrectly|
|000027d0| 20 66 6f 72 20 39 2d 62 | 69 74 20 64 61 63 73 2e | for 9-b|it dacs.|
|000027e0| 20 45 2e 67 2e 20 69 74 | 20 73 65 65 6d 73 20 6c | E.g. it| seems l|
|000027f0| 69 6b 65 6c 79 20 74 68 | 61 74 20 74 68 65 20 0d |ikely th|at the .|
|00002800| 09 09 09 66 69 78 65 64 | 20 70 6f 69 6e 74 20 6d |...fixed| point m|
|00002810| 61 74 68 20 77 69 6c 6c | 20 62 72 65 61 6b 20 69 |ath will| break i|
|00002820| 66 20 56 4d 61 78 20 69 | 73 20 69 6e 63 72 65 61 |f VMax i|s increa|
|00002830| 73 65 64 20 74 6f 20 35 | 31 31 3b 20 61 20 6c 6f |sed to 5|11; a lo|
|00002840| 74 20 6f 66 20 63 61 72 | 65 66 75 6c 20 0d 09 09 |t of car|eful ...|
|00002850| 09 65 72 72 6f 72 20 61 | 6e 61 6c 79 73 69 73 20 |.error a|nalysis |
|00002860| 77 65 6e 74 20 69 6e 74 | 6f 20 74 68 65 20 6f 72 |went int|o the or|
|00002870| 69 67 69 6e 61 6c 20 63 | 6f 64 69 6e 67 2c 20 61 |iginal c|oding, a|
|00002880| 74 20 77 68 69 63 68 20 | 74 69 6d 65 20 49 20 74 |t which |time I t|
|00002890| 68 6f 75 67 68 74 20 74 | 68 61 74 20 0d 09 09 09 |hought t|hat ....|
|000028a0| 69 74 20 77 61 73 20 73 | 61 66 65 20 74 6f 20 61 |it was s|afe to a|
|000028b0| 73 73 75 6d 65 20 61 6e | 20 38 2d 62 69 74 20 64 |ssume an| 8-bit d|
|000028c0| 61 63 20 28 69 2e 65 2e | 20 56 4d 61 78 3d 3d 32 |ac (i.e.| VMax==2|
|000028d0| 35 35 29 2e 20 a5 52 65 | 6d 6f 76 65 64 20 6f 62 |55). .Re|moved ob|
|000028e0| 73 6f 6c 65 74 65 20 0d | 09 09 09 73 75 70 70 6f |solete .|...suppo|
|000028f0| 72 74 20 66 6f 72 20 54 | 48 49 4e 4b 20 43 20 34 |rt for T|HINK C 4|
|00002900| 2e 20 0d 31 32 2f 32 31 | 2f 39 32 20 64 67 70 20 |. .12/21|/92 dgp |
|00002910| 4e 6f 20 6c 6f 6e 67 65 | 72 20 6c 6f 61 64 20 75 |No longe|r load u|
|00002920| 6e 75 73 65 64 20 64 61 | 63 20 62 69 74 73 2e 0d |nused da|c bits..|
|00002930| 31 2f 34 2f 39 33 09 64 | 67 70 09 31 2e 39 35 20 |1/4/93.d|gp.1.95 |
|00002940| 4c 6f 61 64 4c 75 6d 69 | 6e 61 6e 63 65 73 20 6e |LoadLumi|nances n|
|00002950| 6f 77 20 63 68 65 63 6b | 73 20 74 68 65 20 67 64 |ow check|s the gd|
|00002960| 54 79 70 65 2e 0d 2a 2f | 0d 23 69 6e 63 6c 75 64 |Type..*/|.#includ|
|00002970| 65 20 22 56 69 64 65 6f | 54 6f 6f 6c 62 6f 78 2e |e "Video|Toolbox.|
|00002980| 68 22 09 09 2f 2a 20 70 | 72 6f 74 6f 74 79 70 65 |h"../* p|rototype|
|00002990| 20 66 6f 72 20 47 44 53 | 65 74 45 6e 74 72 69 65 | for GDS|etEntrie|
|000029a0| 73 28 29 20 2a 2f 0d 23 | 69 6e 63 6c 75 64 65 20 |s() */.#|include |
|000029b0| 22 4c 75 6d 69 6e 61 6e | 63 65 2e 68 22 0d 23 69 |"Luminan|ce.h".#i|
|000029c0| 6e 63 6c 75 64 65 20 3c | 61 73 73 65 72 74 2e 68 |nclude <|assert.h|
|000029d0| 3e 0d 23 69 6e 63 6c 75 | 64 65 20 3c 6d 61 74 68 |>.#inclu|de <math|
|000029e0| 2e 68 3e 0d 0d 73 74 61 | 74 69 63 20 76 6f 69 64 |.h>..sta|tic void|
|000029f0| 20 53 6f 72 74 28 69 6e | 74 20 6e 2c 64 6f 75 62 | Sort(in|t n,doub|
|00002a00| 6c 65 20 61 72 72 5b 5d | 2c 69 6e 74 20 6b 72 72 |le arr[]|,int krr|
|00002a10| 5b 5d 29 3b 09 2f 2a 20 | 66 6f 72 20 69 6e 74 65 |[]);./* |for inte|
|00002a20| 72 6e 61 6c 20 75 73 65 | 20 6f 6e 6c 79 20 2a 2f |rnal use| only */|
|00002a30| 0d 0d 23 75 6e 64 65 66 | 20 4c 6f 6e 67 54 6f 46 |..#undef| LongToF|
|00002a40| 69 78 0d 23 75 6e 64 65 | 66 20 46 69 78 54 6f 4c |ix.#unde|f FixToL|
|00002a50| 6f 6e 67 0d 23 75 6e 64 | 65 66 20 44 6f 75 62 6c |ong.#und|ef Doubl|
|00002a60| 65 54 6f 46 69 78 0d 23 | 75 6e 64 65 66 20 46 69 |eToFix.#|undef Fi|
|00002a70| 78 54 6f 44 6f 75 62 6c | 65 0d 23 69 66 20 46 41 |xToDoubl|e.#if FA|
|00002a80| 53 54 5f 4c 55 4d 49 4e | 41 4e 43 45 0d 09 23 64 |ST_LUMIN|ANCE..#d|
|00002a90| 65 66 69 6e 65 20 46 49 | 58 45 44 20 46 69 78 65 |efine FI|XED Fixe|
|00002aa0| 64 0d 09 23 69 66 20 21 | 4d 41 43 49 4e 54 4f 53 |d..#if !|MACINTOS|
|00002ab0| 48 0d 09 09 74 79 70 65 | 64 65 66 20 6c 6f 6e 67 |H...type|def long|
|00002ac0| 20 46 69 78 65 64 3b 0d | 09 09 23 64 65 66 69 6e | Fixed;.|..#defin|
|00002ad0| 65 20 46 69 78 4d 75 6c | 28 78 2c 79 29 20 44 6f |e FixMul|(x,y) Do|
|00002ae0| 75 62 6c 65 54 6f 46 69 | 78 28 46 69 78 54 6f 44 |ubleToFi|x(FixToD|
|00002af0| 6f 75 62 6c 65 28 78 29 | 2a 46 69 78 54 6f 44 6f |ouble(x)|*FixToDo|
|00002b00| 75 62 6c 65 28 79 29 29 | 0d 09 09 23 64 65 66 69 |uble(y))|...#defi|
|00002b10| 6e 65 20 46 69 78 44 69 | 76 28 78 2c 79 29 20 44 |ne FixDi|v(x,y) D|
|00002b20| 6f 75 62 6c 65 54 6f 46 | 69 78 28 46 69 78 54 6f |oubleToF|ix(FixTo|
|00002b30| 44 6f 75 62 6c 65 28 78 | 29 2f 46 69 78 54 6f 44 |Double(x|)/FixToD|
|00002b40| 6f 75 62 6c 65 28 79 29 | 29 0d 09 23 65 6e 64 69 |ouble(y)|)..#endi|
|00002b50| 66 0d 09 23 64 65 66 69 | 6e 65 20 4c 6f 6e 67 54 |f..#defi|ne LongT|
|00002b60| 6f 46 69 78 28 78 29 20 | 28 28 6c 6f 6e 67 29 28 |oFix(x) |((long)(|
|00002b70| 78 29 3c 3c 31 36 29 0d | 09 23 64 65 66 69 6e 65 |x)<<16).|.#define|
|00002b80| 20 46 69 78 54 6f 4c 6f | 6e 67 28 78 29 20 28 28 | FixToLo|ng(x) ((|
|00002b90| 78 29 3e 3e 31 36 29 0d | 09 23 64 65 66 69 6e 65 |x)>>16).|.#define|
|00002ba0| 20 44 6f 75 62 6c 65 54 | 6f 46 69 78 28 78 29 20 | DoubleT|oFix(x) |
|00002bb0| 28 28 46 69 78 65 64 29 | 28 28 78 29 2a 36 35 35 |((Fixed)|((x)*655|
|00002bc0| 33 36 2e 2b 30 2e 35 29 | 29 0d 09 23 64 65 66 69 |36.+0.5)|)..#defi|
|00002bd0| 6e 65 20 46 69 78 54 6f | 44 6f 75 62 6c 65 28 78 |ne FixTo|Double(x|
|00002be0| 29 20 28 28 64 6f 75 62 | 6c 65 29 28 78 29 2a 28 |) ((doub|le)(x)*(|
|00002bf0| 31 2e 2f 36 35 35 33 36 | 2e 29 29 0d 09 23 64 65 |1./65536|.))..#de|
|00002c00| 66 69 6e 65 20 44 28 78 | 29 20 46 69 78 54 6f 44 |fine D(x|) FixToD|
|00002c10| 6f 75 62 6c 65 28 78 29 | 09 09 09 09 09 09 09 2f |ouble(x)|......./|
|00002c20| 2a 20 68 61 6e 64 79 20 | 66 6f 72 20 64 65 62 75 |* handy |for debu|
|00002c30| 67 67 69 6e 67 20 2a 2f | 0d 23 65 6c 73 65 0d 09 |gging */|.#else..|
|00002c40| 23 64 65 66 69 6e 65 20 | 46 49 58 45 44 20 64 6f |#define |FIXED do|
|00002c50| 75 62 6c 65 0d 09 23 64 | 65 66 69 6e 65 20 46 69 |uble..#d|efine Fi|
|00002c60| 78 4d 75 6c 28 78 2c 79 | 29 20 28 28 64 6f 75 62 |xMul(x,y|) ((doub|
|00002c70| 6c 65 29 28 78 29 2a 28 | 79 29 29 0d 09 23 64 65 |le)(x)*(|y))..#de|
|00002c80| 66 69 6e 65 20 46 69 78 | 44 69 76 28 78 2c 79 29 |fine Fix|Div(x,y)|
|00002c90| 20 28 28 64 6f 75 62 6c | 65 29 28 78 29 2f 28 79 | ((doubl|e)(x)/(y|
|00002ca0| 29 29 0d 09 23 64 65 66 | 69 6e 65 20 4c 6f 6e 67 |))..#def|ine Long|
|00002cb0| 54 6f 46 69 78 28 78 29 | 20 28 28 64 6f 75 62 6c |ToFix(x)| ((doubl|
|00002cc0| 65 29 28 78 29 29 0d 09 | 23 64 65 66 69 6e 65 20 |e)(x))..|#define |
|00002cd0| 46 69 78 54 6f 4c 6f 6e | 67 28 78 29 20 28 28 6c |FixToLon|g(x) ((l|
|00002ce0| 6f 6e 67 29 28 78 29 29 | 0d 09 23 64 65 66 69 6e |ong)(x))|..#defin|
|00002cf0| 65 20 44 6f 75 62 6c 65 | 54 6f 46 69 78 28 78 29 |e Double|ToFix(x)|
|00002d00| 20 28 28 64 6f 75 62 6c | 65 29 28 78 29 29 0d 09 | ((doubl|e)(x))..|
|00002d10| 23 64 65 66 69 6e 65 20 | 46 69 78 54 6f 44 6f 75 |#define |FixToDou|
|00002d20| 62 6c 65 28 78 29 20 28 | 28 64 6f 75 62 6c 65 29 |ble(x) (|(double)|
|00002d30| 28 78 29 29 0d 23 65 6e | 64 69 66 0d 0d 23 75 6e |(x)).#en|dif..#un|
|00002d40| 64 65 66 20 4d 41 58 0d | 23 75 6e 64 65 66 20 4d |def MAX.|#undef M|
|00002d50| 49 4e 0d 23 64 65 66 69 | 6e 65 20 4d 41 58 28 61 |IN.#defi|ne MAX(a|
|00002d60| 2c 62 29 20 28 28 61 29 | 20 3e 20 28 62 29 20 3f |,b) ((a)| > (b) ?|
|00002d70| 20 28 61 29 20 3a 20 28 | 62 29 29 0d 23 64 65 66 | (a) : (|b)).#def|
|00002d80| 69 6e 65 20 4d 49 4e 28 | 61 2c 62 29 20 28 28 61 |ine MIN(|a,b) ((a|
|00002d90| 29 20 3c 20 28 62 29 20 | 3f 20 28 61 29 20 3a 20 |) < (b) |? (a) : |
|00002da0| 28 62 29 29 0d 0d 64 6f | 75 62 6c 65 20 53 65 74 |(b))..do|uble Set|
|00002db0| 4c 75 6d 69 6e 61 6e 63 | 65 28 47 44 48 61 6e 64 |Luminanc|e(GDHand|
|00002dc0| 6c 65 20 64 65 76 69 63 | 65 2c 6c 75 6d 69 6e 61 |le devic|e,lumina|
|00002dd0| 6e 63 65 52 65 63 6f 72 | 64 20 2a 4c 50 0d 09 2c |nceRecor|d *LP..,|
|00002de0| 69 6e 74 20 74 68 65 45 | 6e 74 72 79 2c 64 6f 75 |int theE|ntry,dou|
|00002df0| 62 6c 65 20 6c 75 6d 69 | 6e 61 6e 63 65 0d 09 2c |ble lumi|nance..,|
|00002e00| 64 6f 75 62 6c 65 20 6c | 6f 77 4c 75 6d 69 6e 61 |double l|owLumina|
|00002e10| 6e 63 65 2c 64 6f 75 62 | 6c 65 20 68 69 67 68 4c |nce,doub|le highL|
|00002e20| 75 6d 69 6e 61 6e 63 65 | 29 0d 2f 2a 0d 53 65 74 |uminance|)./*.Set|
|00002e30| 20 6f 6e 65 20 65 6e 74 | 72 79 20 69 6e 20 74 68 | one ent|ry in th|
|00002e40| 65 20 43 6f 6c 6f 72 53 | 70 65 63 20 74 61 62 6c |e ColorS|pec tabl|
|00002e50| 65 20 28 61 6e 64 20 74 | 68 65 20 63 6c 75 74 20 |e (and t|he clut |
|00002e60| 69 66 20 64 65 76 69 63 | 65 20 69 73 20 6e 6f 74 |if devic|e is not|
|00002e70| 20 4e 55 4c 4c 29 20 74 | 6f 0d 61 20 73 70 65 63 | NULL) t|o.a spec|
|00002e80| 69 66 69 65 64 20 6c 75 | 6d 69 6e 61 6e 63 65 2e |ified lu|minance.|
|00002e90| 20 49 74 27 73 20 6f 6b | 20 66 6f 72 20 6c 6f 77 | It's ok| for low|
|00002ea0| 4c 75 6d 69 6e 61 6e 63 | 65 20 74 6f 20 62 65 20 |Luminanc|e to be |
|00002eb0| 67 72 65 61 74 65 72 20 | 74 68 61 6e 20 68 69 67 |greater |than hig|
|00002ec0| 68 4c 75 6d 69 6e 61 6e | 63 65 3b 20 0d 74 68 65 |hLuminan|ce; .the|
|00002ed0| 79 20 73 74 69 6c 6c 20 | 64 65 73 69 67 6e 61 74 |y still |designat|
|00002ee0| 65 20 61 20 72 61 6e 67 | 65 2e 0d 2a 2f 0d 7b 0d |e a rang|e..*/.{.|
|00002ef0| 09 46 49 58 45 44 20 5f | 6c 75 6d 69 6e 61 6e 63 |.FIXED _|luminanc|
|00002f00| 65 3b 0d 09 0d 09 69 66 | 28 74 68 65 45 6e 74 72 |e;....if|(theEntr|
|00002f10| 79 3c 30 20 7c 7c 20 74 | 68 65 45 6e 74 72 79 3e |y<0 || t|heEntry>|
|00002f20| 3d 43 4f 4c 4f 52 53 20 | 0d 09 09 7c 7c 20 64 65 |=COLORS |...|| de|
|00002f30| 76 69 63 65 21 3d 4e 55 | 4c 4c 20 26 26 20 74 68 |vice!=NU|LL && th|
|00002f40| 65 45 6e 74 72 79 3e 3d | 47 44 43 4f 4c 4f 52 53 |eEntry>=|GDCOLORS|
|00002f50| 28 64 65 76 69 63 65 29 | 29 0d 09 09 09 50 72 69 |(device)|)....Pri|
|00002f60| 6e 74 66 45 78 69 74 28 | 22 5c 30 30 37 53 65 74 |ntfExit(|"\007Set|
|00002f70| 4c 75 6d 69 6e 61 6e 63 | 65 3a 20 69 6c 6c 65 67 |Luminanc|e: illeg|
|00002f80| 61 6c 20 65 6e 74 72 79 | 20 25 64 5c 6e 22 2c 74 |al entry| %d\n",t|
|00002f90| 68 65 45 6e 74 72 79 29 | 3b 0d 09 0d 09 53 65 74 |heEntry)|;....Set|
|00002fa0| 4c 75 6d 69 6e 61 6e 63 | 65 52 61 6e 67 65 28 4c |Luminanc|eRange(L|
|00002fb0| 50 2c 6c 6f 77 4c 75 6d | 69 6e 61 6e 63 65 2c 68 |P,lowLum|inance,h|
|00002fc0| 69 67 68 4c 75 6d 69 6e | 61 6e 63 65 29 3b 0d 09 |ighLumin|ance);..|
|00002fd0| 5f 6c 75 6d 69 6e 61 6e | 63 65 3d 44 6f 75 62 6c |_luminan|ce=Doubl|
|00002fe0| 65 54 6f 46 69 78 28 6c | 75 6d 69 6e 61 6e 63 65 |eToFix(l|uminance|
|00002ff0| 29 3b 0d 09 5f 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |);.._Set|Luminanc|
|00003000| 65 28 4c 50 2c 74 68 65 | 45 6e 74 72 79 2c 5f 6c |e(LP,the|Entry,_l|
|00003010| 75 6d 69 6e 61 6e 63 65 | 29 3b 0d 09 69 66 28 64 |uminance|);..if(d|
|00003020| 65 76 69 63 65 20 21 3d | 20 4e 55 4c 4c 29 4c 6f |evice !=| NULL)Lo|
|00003030| 61 64 4c 75 6d 69 6e 61 | 6e 63 65 73 28 64 65 76 |adLumina|nces(dev|
|00003040| 69 63 65 2c 4c 50 2c 74 | 68 65 45 6e 74 72 79 2c |ice,LP,t|heEntry,|
|00003050| 74 68 65 45 6e 74 72 79 | 29 3b 0d 09 72 65 74 75 |theEntry|);..retu|
|00003060| 72 6e 20 46 69 78 54 6f | 44 6f 75 62 6c 65 28 5f |rn FixTo|Double(_|
|00003070| 54 6f 6c 65 72 61 6e 63 | 65 28 4c 50 2c 5f 6c 75 |Toleranc|e(LP,_lu|
|00003080| 6d 69 6e 61 6e 63 65 29 | 29 3b 0d 7d 0d 0d 64 6f |minance)|);.}..do|
|00003090| 75 62 6c 65 20 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |uble Set|Luminanc|
|000030a0| 65 73 28 47 44 48 61 6e | 64 6c 65 20 64 65 76 69 |es(GDHan|dle devi|
|000030b0| 63 65 2c 6c 75 6d 69 6e | 61 6e 63 65 52 65 63 6f |ce,lumin|anceReco|
|000030c0| 72 64 20 2a 4c 50 0d 09 | 2c 69 6e 74 20 66 69 72 |rd *LP..|,int fir|
|000030d0| 73 74 45 6e 74 72 79 2c | 69 6e 74 20 6c 61 73 74 |stEntry,|int last|
|000030e0| 45 6e 74 72 79 0d 09 2c | 64 6f 75 62 6c 65 20 66 |Entry..,|double f|
|000030f0| 69 72 73 74 4c 75 6d 69 | 6e 61 6e 63 65 2c 64 6f |irstLumi|nance,do|
|00003100| 75 62 6c 65 20 6c 61 73 | 74 4c 75 6d 69 6e 61 6e |uble las|tLuminan|
|00003110| 63 65 29 0d 2f 2a 0d 53 | 65 74 20 61 20 73 65 72 |ce)./*.S|et a ser|
|00003120| 69 65 73 20 6f 66 20 65 | 6e 74 72 69 65 73 20 69 |ies of e|ntries i|
|00003130| 6e 20 74 68 65 20 43 6f | 6c 6f 72 53 70 65 63 20 |n the Co|lorSpec |
|00003140| 74 61 62 6c 65 20 28 61 | 6e 64 20 74 68 65 20 63 |table (a|nd the c|
|00003150| 6c 75 74 20 69 66 20 64 | 65 76 69 63 65 20 69 73 |lut if d|evice is|
|00003160| 20 6e 6f 74 20 4e 55 4c | 4c 29 0d 74 6f 20 61 20 | not NUL|L).to a |
|00003170| 6c 69 6e 65 61 72 20 73 | 65 71 75 65 6e 63 65 20 |linear s|equence |
|00003180| 6f 66 20 6c 75 6d 69 6e | 61 6e 63 65 73 2e 20 41 |of lumin|ances. A|
|00003190| 73 73 75 6d 65 20 74 68 | 69 73 20 69 73 20 74 68 |ssume th|is is th|
|000031a0| 65 20 65 6e 74 69 72 65 | 20 6c 75 6d 69 6e 61 6e |e entire| luminan|
|000031b0| 63 65 20 72 61 6e 67 65 | 20 6f 66 20 0d 69 6e 74 |ce range| of .int|
|000031c0| 65 72 65 73 74 2e 0d 2a | 2f 0d 7b 0d 09 72 65 74 |erest..*|/.{..ret|
|000031d0| 75 72 6e 20 53 65 74 4c | 75 6d 69 6e 61 6e 63 65 |urn SetL|uminance|
|000031e0| 73 41 6e 64 52 61 6e 67 | 65 28 64 65 76 69 63 65 |sAndRang|e(device|
|000031f0| 2c 4c 50 2c 66 69 72 73 | 74 45 6e 74 72 79 2c 6c |,LP,firs|tEntry,l|
|00003200| 61 73 74 45 6e 74 72 79 | 0d 09 09 2c 66 69 72 73 |astEntry|...,firs|
|00003210| 74 4c 75 6d 69 6e 61 6e | 63 65 2c 6c 61 73 74 4c |tLuminan|ce,lastL|
|00003220| 75 6d 69 6e 61 6e 63 65 | 2c 66 69 72 73 74 4c 75 |uminance|,firstLu|
|00003230| 6d 69 6e 61 6e 63 65 2c | 6c 61 73 74 4c 75 6d 69 |minance,|lastLumi|
|00003240| 6e 61 6e 63 65 29 3b 0d | 7d 0d 0d 64 6f 75 62 6c |nance);.|}..doubl|
|00003250| 65 20 53 65 74 4c 75 6d | 69 6e 61 6e 63 65 73 41 |e SetLum|inancesA|
|00003260| 6e 64 52 61 6e 67 65 28 | 47 44 48 61 6e 64 6c 65 |ndRange(|GDHandle|
|00003270| 20 64 65 76 69 63 65 2c | 6c 75 6d 69 6e 61 6e 63 | device,|luminanc|
|00003280| 65 52 65 63 6f 72 64 20 | 2a 4c 50 0d 09 2c 69 6e |eRecord |*LP..,in|
|00003290| 74 20 66 69 72 73 74 45 | 6e 74 72 79 2c 69 6e 74 |t firstE|ntry,int|
|000032a0| 20 6c 61 73 74 45 6e 74 | 72 79 0d 09 2c 64 6f 75 | lastEnt|ry..,dou|
|000032b0| 62 6c 65 20 66 69 72 73 | 74 4c 75 6d 69 6e 61 6e |ble firs|tLuminan|
|000032c0| 63 65 2c 64 6f 75 62 6c | 65 20 6c 61 73 74 4c 75 |ce,doubl|e lastLu|
|000032d0| 6d 69 6e 61 6e 63 65 0d | 09 2c 64 6f 75 62 6c 65 |minance.|.,double|
|000032e0| 20 6c 6f 77 4c 75 6d 69 | 6e 61 6e 63 65 2c 64 6f | lowLumi|nance,do|
|000032f0| 75 62 6c 65 20 68 69 67 | 68 4c 75 6d 69 6e 61 6e |uble hig|hLuminan|
|00003300| 63 65 29 0d 2f 2a 0d 53 | 65 74 20 61 20 73 65 72 |ce)./*.S|et a ser|
|00003310| 69 65 73 20 6f 66 20 65 | 6e 74 72 69 65 73 20 69 |ies of e|ntries i|
|00003320| 6e 20 74 68 65 20 43 6f | 6c 6f 72 53 70 65 63 20 |n the Co|lorSpec |
|00003330| 74 61 62 6c 65 20 28 61 | 6e 64 20 74 68 65 20 63 |table (a|nd the c|
|00003340| 6c 75 74 20 69 66 20 64 | 65 76 69 63 65 20 69 73 |lut if d|evice is|
|00003350| 20 6e 6f 74 0d 4e 55 4c | 4c 29 20 74 6f 20 61 20 | not.NUL|L) to a |
|00003360| 6c 69 6e 65 61 72 20 73 | 65 71 75 65 6e 63 65 20 |linear s|equence |
|00003370| 6f 66 20 6c 75 6d 69 6e | 61 6e 63 65 73 2e 20 55 |of lumin|ances. U|
|00003380| 73 65 73 20 6c 61 73 74 | 20 74 77 6f 20 61 72 67 |ses last| two arg|
|00003390| 75 6d 65 6e 74 73 20 74 | 6f 20 73 65 74 20 74 68 |uments t|o set th|
|000033a0| 65 0d 6c 75 6d 69 6e 61 | 6e 63 65 20 72 61 6e 67 |e.lumina|nce rang|
|000033b0| 65 2e 0d 0d 49 20 69 6e | 74 72 6f 64 75 63 65 64 |e...I in|troduced|
|000033c0| 20 61 20 73 74 61 63 6b | 2d 73 70 61 63 65 20 63 | a stack|-space c|
|000033d0| 68 65 63 6b 20 62 65 66 | 6f 72 65 20 63 61 6c 6c |heck bef|ore call|
|000033e0| 69 6e 67 20 5f 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |ing _Set|Luminanc|
|000033f0| 65 73 28 29 2c 20 73 69 | 6e 63 65 20 69 74 20 63 |es(), si|nce it c|
|00003400| 61 6c 6c 73 0d 69 74 73 | 65 6c 66 20 72 65 63 75 |alls.its|elf recu|
|00003410| 72 73 69 76 65 6c 79 20 | 61 6e 64 20 6d 61 79 20 |rsively |and may |
|00003420| 75 73 65 20 31 30 30 30 | 20 62 79 74 65 73 20 61 |use 1000| bytes a|
|00003430| 6c 6c 20 74 6f 67 65 74 | 68 65 72 2e 20 48 6f 77 |ll toget|her. How|
|00003440| 65 76 65 72 2c 20 70 72 | 69 6e 74 69 6e 67 20 61 |ever, pr|inting a|
|00003450| 6e 0d 65 72 72 6f 72 20 | 6d 65 73 73 61 67 65 20 |n.error |message |
|00003460| 72 65 71 75 69 72 65 73 | 20 61 74 20 6c 65 61 73 |requires| at leas|
|00003470| 74 20 34 35 30 30 20 62 | 79 74 65 73 2e 20 53 6f |t 4500 b|ytes. So|
|00003480| 20 49 20 71 75 69 74 20 | 69 66 20 74 68 65 20 73 | I quit |if the s|
|00003490| 74 61 63 6b 20 67 65 74 | 73 20 62 65 6c 6f 77 0d |tack get|s below.|
|000034a0| 36 30 30 30 2c 20 73 6f | 20 74 68 61 74 20 74 68 |6000, so| that th|
|000034b0| 65 20 75 73 65 72 20 77 | 69 6c 6c 20 62 65 20 70 |e user w|ill be p|
|000034c0| 72 65 73 65 6e 74 65 64 | 20 77 69 74 68 20 61 6e |resented| with an|
|000034d0| 20 75 6e 64 65 72 73 74 | 61 6e 64 61 62 6c 65 20 | underst|andable |
|000034e0| 65 72 72 6f 72 20 6d 65 | 73 73 61 67 65 0d 72 61 |error me|ssage.ra|
|000034f0| 74 68 65 72 20 74 68 61 | 6e 20 61 20 6d 79 73 74 |ther tha|n a myst|
|00003500| 65 72 69 6f 75 73 20 71 | 75 69 74 20 6f 72 20 63 |erious q|uit or c|
|00003510| 72 61 73 68 2e 0d 2a 2f | 0d 7b 0d 09 46 49 58 45 |rash..*/|.{..FIXE|
|00003520| 44 20 5f 74 6f 6c 65 72 | 61 6e 63 65 2c 5f 74 2c |D _toler|ance,_t,|
|00003530| 5f 64 4c 36 34 3b 0d 09 | 46 49 58 45 44 20 5f 66 |_dL64;..|FIXED _f|
|00003540| 69 72 73 74 4c 2c 5f 6c | 61 73 74 4c 2c 5f 66 69 |irstL,_l|astL,_fi|
|00003550| 72 73 74 56 2c 5f 6c 61 | 73 74 56 3b 0d 09 0d 09 |rstV,_la|stV;....|
|00003560| 69 66 28 66 69 72 73 74 | 45 6e 74 72 79 3c 30 20 |if(first|Entry<0 |
|00003570| 7c 7c 20 66 69 72 73 74 | 45 6e 74 72 79 3e 6c 61 ||| first|Entry>la|
|00003580| 73 74 45 6e 74 72 79 20 | 7c 7c 20 6c 61 73 74 45 |stEntry ||| lastE|
|00003590| 6e 74 72 79 3e 3d 43 4f | 4c 4f 52 53 20 0d 09 09 |ntry>=CO|LORS ...|
|000035a0| 7c 7c 20 64 65 76 69 63 | 65 21 3d 4e 55 4c 4c 20 ||| devic|e!=NULL |
|000035b0| 26 26 20 6c 61 73 74 45 | 6e 74 72 79 3e 3d 47 44 |&& lastE|ntry>=GD|
|000035c0| 43 4f 4c 4f 52 53 28 64 | 65 76 69 63 65 29 20 29 |COLORS(d|evice) )|
|000035d0| 0d 09 09 50 72 69 6e 74 | 66 45 78 69 74 28 22 5c |...Print|fExit("\|
|000035e0| 30 30 37 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 73 |007SetLu|minances|
|000035f0| 41 6e 64 52 61 6e 67 65 | 3a 20 69 6c 6c 65 67 61 |AndRange|: illega|
|00003600| 6c 20 65 6e 74 72 69 65 | 73 20 25 64 20 25 64 5c |l entrie|s %d %d\|
|00003610| 6e 22 2c 66 69 72 73 74 | 45 6e 74 72 79 2c 6c 61 |n",first|Entry,la|
|00003620| 73 74 45 6e 74 72 79 29 | 3b 0d 09 69 66 28 53 74 |stEntry)|;..if(St|
|00003630| 61 63 6b 53 70 61 63 65 | 28 29 3c 36 30 30 30 29 |ackSpace|()<6000)|
|00003640| 50 72 69 6e 74 66 45 78 | 69 74 28 22 53 65 74 4c |PrintfEx|it("SetL|
|00003650| 75 6d 69 6e 61 6e 63 65 | 73 41 6e 64 52 61 6e 67 |uminance|sAndRang|
|00003660| 65 3a 20 6e 6f 74 20 65 | 6e 6f 75 67 68 20 73 74 |e: not e|nough st|
|00003670| 61 63 6b 20 73 70 61 63 | 65 2e 5c 30 30 37 5c 6e |ack spac|e.\007\n|
|00003680| 22 29 3b 0d 09 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |");..Set|Luminanc|
|00003690| 65 52 61 6e 67 65 28 4c | 50 2c 6c 6f 77 4c 75 6d |eRange(L|P,lowLum|
|000036a0| 69 6e 61 6e 63 65 2c 68 | 69 67 68 4c 75 6d 69 6e |inance,h|ighLumin|
|000036b0| 61 6e 63 65 29 3b 0d 09 | 5f 66 69 72 73 74 4c 3d |ance);..|_firstL=|
|000036c0| 44 6f 75 62 6c 65 54 6f | 46 69 78 28 66 69 72 73 |DoubleTo|Fix(firs|
|000036d0| 74 4c 75 6d 69 6e 61 6e | 63 65 29 3b 0d 09 5f 6c |tLuminan|ce);.._l|
|000036e0| 61 73 74 4c 3d 44 6f 75 | 62 6c 65 54 6f 46 69 78 |astL=Dou|bleToFix|
|000036f0| 28 6c 61 73 74 4c 75 6d | 69 6e 61 6e 63 65 29 3b |(lastLum|inance);|
|00003700| 0d 09 5f 66 69 72 73 74 | 56 3d 5f 4c 54 6f 56 28 |.._first|V=_LToV(|
|00003710| 4c 50 2c 5f 66 69 72 73 | 74 4c 20 2b 20 4c 50 2d |LP,_firs|tL + LP-|
|00003720| 3e 5f 4c 4f 66 66 73 65 | 74 29 3b 0d 09 5f 6c 61 |>_LOffse|t);.._la|
|00003730| 73 74 56 3d 5f 4c 54 6f | 56 28 4c 50 2c 5f 6c 61 |stV=_LTo|V(LP,_la|
|00003740| 73 74 4c 20 2b 20 4c 50 | 2d 3e 5f 4c 4f 66 66 73 |stL + LP|->_LOffs|
|00003750| 65 74 29 3b 0d 09 69 66 | 28 6c 61 73 74 45 6e 74 |et);..if|(lastEnt|
|00003760| 72 79 20 21 3d 20 66 69 | 72 73 74 45 6e 74 72 79 |ry != fi|rstEntry|
|00003770| 29 0d 09 09 23 69 66 20 | 46 41 53 54 5f 4c 55 4d |)...#if |FAST_LUM|
|00003780| 49 4e 41 4e 43 45 0d 09 | 09 5f 64 4c 36 34 3d 44 |INANCE..|._dL64=D|
|00003790| 6f 75 62 6c 65 54 6f 46 | 69 78 28 36 34 2e 30 2a |oubleToF|ix(64.0*|
|000037a0| 28 6c 61 73 74 4c 75 6d | 69 6e 61 6e 63 65 2d 66 |(lastLum|inance-f|
|000037b0| 69 72 73 74 4c 75 6d 69 | 6e 61 6e 63 65 29 2f 28 |irstLumi|nance)/(|
|000037c0| 6c 61 73 74 45 6e 74 72 | 79 2d 66 69 72 73 74 45 |lastEntr|y-firstE|
|000037d0| 6e 74 72 79 29 29 3b 0d | 09 09 23 65 6c 73 65 0d |ntry));.|..#else.|
|000037e0| 09 09 5f 64 4c 36 34 3d | 44 6f 75 62 6c 65 54 6f |.._dL64=|DoubleTo|
|000037f0| 46 69 78 28 28 6c 61 73 | 74 4c 75 6d 69 6e 61 6e |Fix((las|tLuminan|
|00003800| 63 65 2d 66 69 72 73 74 | 4c 75 6d 69 6e 61 6e 63 |ce-first|Luminanc|
|00003810| 65 29 2f 28 6c 61 73 74 | 45 6e 74 72 79 2d 66 69 |e)/(last|Entry-fi|
|00003820| 72 73 74 45 6e 74 72 79 | 29 29 3b 0d 09 09 23 65 |rstEntry|));...#e|
|00003830| 6e 64 69 66 0d 09 65 6c | 73 65 0d 09 09 5f 64 4c |ndif..el|se..._dL|
|00003840| 36 34 3d 30 3b 0d 09 5f | 53 65 74 4c 75 6d 69 6e |64=0;.._|SetLumin|
|00003850| 61 6e 63 65 73 28 4c 50 | 2c 66 69 72 73 74 45 6e |ances(LP|,firstEn|
|00003860| 74 72 79 2c 6c 61 73 74 | 45 6e 74 72 79 2c 5f 66 |try,last|Entry,_f|
|00003870| 69 72 73 74 4c 2c 5f 64 | 4c 36 34 2c 5f 66 69 72 |irstL,_d|L64,_fir|
|00003880| 73 74 56 2c 5f 6c 61 73 | 74 56 29 3b 0d 09 69 66 |stV,_las|tV);..if|
|00003890| 28 64 65 76 69 63 65 20 | 21 3d 20 4e 55 4c 4c 29 |(device |!= NULL)|
|000038a0| 4c 6f 61 64 4c 75 6d 69 | 6e 61 6e 63 65 73 28 64 |LoadLumi|nances(d|
|000038b0| 65 76 69 63 65 2c 4c 50 | 2c 66 69 72 73 74 45 6e |evice,LP|,firstEn|
|000038c0| 74 72 79 2c 6c 61 73 74 | 45 6e 74 72 79 29 3b 09 |try,last|Entry);.|
|000038d0| 0d 09 0d 09 2f 2a 20 71 | 75 69 63 6b 20 61 6e 64 |..../* q|uick and|
|000038e0| 20 64 69 72 74 79 20 65 | 73 74 69 6d 61 74 65 20 | dirty e|stimate |
|000038f0| 6f 66 20 74 6f 6c 65 72 | 61 6e 63 65 20 2a 2f 0d |of toler|ance */.|
|00003900| 09 5f 74 6f 6c 65 72 61 | 6e 63 65 3d 4c 50 2d 3e |._tolera|nce=LP->|
|00003910| 4c 2e 5f 4c 5b 30 5d 20 | 2d 20 5f 66 69 72 73 74 |L._L[0] |- _first|
|00003920| 4c 3b 0d 09 5f 74 3d 5f | 6c 61 73 74 4c 20 2d 20 |L;.._t=_|lastL - |
|00003930| 4c 50 2d 3e 4c 2e 5f 4c | 5b 4c 55 4d 49 4e 41 4e |LP->L._L|[LUMINAN|
|00003940| 43 45 53 5f 49 4e 5f 54 | 41 42 4c 45 2d 31 5d 3b |CES_IN_T|ABLE-1];|
|00003950| 0d 09 69 66 28 5f 74 6f | 6c 65 72 61 6e 63 65 3c |..if(_to|lerance<|
|00003960| 5f 74 29 5f 74 6f 6c 65 | 72 61 6e 63 65 3d 5f 74 |_t)_tole|rance=_t|
|00003970| 3b 0d 09 69 66 28 5f 74 | 6f 6c 65 72 61 6e 63 65 |;..if(_t|olerance|
|00003980| 3c 30 29 5f 74 6f 6c 65 | 72 61 6e 63 65 3d 30 3b |<0)_tole|rance=0;|
|00003990| 0d 09 5f 74 6f 6c 65 72 | 61 6e 63 65 2b 3d 4c 50 |.._toler|ance+=LP|
|000039a0| 2d 3e 5f 74 6f 6c 65 72 | 61 6e 63 65 3b 0d 09 72 |->_toler|ance;..r|
|000039b0| 65 74 75 72 6e 20 46 69 | 78 54 6f 44 6f 75 62 6c |eturn Fi|xToDoubl|
|000039c0| 65 28 5f 74 6f 6c 65 72 | 61 6e 63 65 29 3b 09 2f |e(_toler|ance);./|
|000039d0| 2a 20 65 73 74 69 6d 61 | 74 65 20 6f 66 20 6d 61 |* estima|te of ma|
|000039e0| 78 20 65 72 72 6f 72 20 | 69 6e 20 c6 4c 20 2a 2f |x error |in .L */|
|000039f0| 0d 7d 0d 0d 76 6f 69 64 | 20 5f 53 65 74 4c 75 6d |.}..void| _SetLum|
|00003a00| 69 6e 61 6e 63 65 73 28 | 6c 75 6d 69 6e 61 6e 63 |inances(|luminanc|
|00003a10| 65 52 65 63 6f 72 64 20 | 2a 4c 50 74 72 2c 69 6e |eRecord |*LPtr,in|
|00003a20| 74 20 66 69 72 73 74 2c | 69 6e 74 20 6c 61 73 74 |t first,|int last|
|00003a30| 0d 09 2c 46 49 58 45 44 | 20 5f 66 69 72 73 74 4c |..,FIXED| _firstL|
|00003a40| 2c 46 49 58 45 44 20 5f | 64 4c 36 34 2c 46 49 58 |,FIXED _|dL64,FIX|
|00003a50| 45 44 20 5f 66 69 72 73 | 74 56 2c 46 49 58 45 44 |ED _firs|tV,FIXED|
|00003a60| 20 5f 6c 61 73 74 56 29 | 0d 2f 2a 0d 54 68 69 73 | _lastV)|./*.This|
|00003a70| 20 72 6f 75 74 69 6e 65 | 20 65 6c 69 6d 69 6e 61 | routine| elimina|
|00003a80| 74 65 73 20 6d 6f 73 74 | 20 6f 66 20 74 68 65 20 |tes most| of the |
|00003a90| 74 68 65 20 73 6c 6f 77 | 20 5f 4c 54 6f 56 28 29 |the slow| _LToV()|
|00003aa0| 20 74 61 62 6c 65 20 6c | 6f 6f 6b 75 70 73 20 61 | table l|ookups a|
|00003ab0| 6e 64 0d 69 6e 74 65 72 | 70 6f 6c 61 74 69 6f 6e |nd.inter|polation|
|00003ac0| 73 20 62 79 20 61 73 73 | 75 6d 69 6e 67 20 74 68 |s by ass|uming th|
|00003ad0| 61 74 20 74 68 65 20 67 | 61 6d 6d 61 20 66 75 6e |at the g|amma fun|
|00003ae0| 63 74 69 6f 6e 20 69 73 | 20 73 6d 6f 6f 74 68 20 |ction is| smooth |
|00003af0| 65 6e 6f 75 67 68 20 74 | 68 61 74 20 77 65 20 6d |enough t|hat we m|
|00003b00| 61 79 0d 6c 69 6e 65 61 | 72 6c 79 20 69 6e 74 65 |ay.linea|rly inte|
|00003b10| 72 70 6f 6c 61 74 65 20 | 6f 76 65 72 20 61 6e 79 |rpolate |over any|
|00003b20| 20 69 6e 74 65 72 76 61 | 6c 20 6f 66 20 56 20 6e | interva|l of V n|
|00003b30| 6f 20 77 69 64 65 72 20 | 74 68 61 6e 20 4c 49 4e |o wider |than LIN|
|00003b40| 45 41 52 5f 56 5f 44 4f | 4d 41 49 4e 2e 20 53 69 |EAR_V_DO|MAIN. Si|
|00003b50| 6e 63 65 0d 74 68 65 20 | 67 61 6d 6d 61 20 66 75 |nce.the |gamma fu|
|00003b60| 6e 63 74 69 6f 6e 20 69 | 73 20 72 6f 75 67 68 6c |nction i|s roughl|
|00003b70| 79 20 70 61 72 61 62 6f | 6c 69 63 2c 20 74 68 65 |y parabo|lic, the|
|00003b80| 20 63 6f 6e 73 65 71 75 | 65 6e 74 20 65 72 72 6f | consequ|ent erro|
|00003b90| 72 20 69 6e 20 4c 20 77 | 69 6c 6c 20 62 65 0d 70 |r in L w|ill be.p|
|00003ba0| 72 6f 70 6f 72 74 69 6f | 6e 61 6c 20 74 6f 20 74 |roportio|nal to t|
|00003bb0| 68 65 20 73 71 75 61 72 | 65 20 6f 66 20 4c 49 4e |he squar|e of LIN|
|00003bc0| 45 41 52 5f 56 5f 44 4f | 4d 41 49 4e 2c 20 61 6e |EAR_V_DO|MAIN, an|
|00003bd0| 64 20 69 6e 64 65 70 65 | 6e 64 65 6e 74 20 6f 66 |d indepe|ndent of|
|00003be0| 20 77 68 65 72 65 20 74 | 68 69 73 0d 69 6e 74 65 | where t|his.inte|
|00003bf0| 72 76 61 6c 20 69 73 20 | 61 6c 6f 6e 67 20 56 2e |rval is |along V.|
|00003c00| 20 53 69 6e 63 65 20 77 | 65 27 72 65 20 69 6e 73 | Since w|e're ins|
|00003c10| 63 72 69 62 69 6e 67 20 | 73 74 72 61 69 67 68 74 |cribing |straight|
|00003c20| 20 6c 69 6e 65 20 73 65 | 67 6d 65 6e 74 73 20 69 | line se|gments i|
|00003c30| 6e 20 61 0d 70 6f 73 69 | 74 69 76 65 6c 79 20 61 |n a.posi|tively a|
|00003c40| 63 63 65 6c 65 72 61 74 | 69 6e 67 20 67 61 6d 6d |ccelerat|ing gamm|
|00003c50| 61 20 66 75 6e 63 74 69 | 6f 6e 2c 20 77 65 20 77 |a functi|on, we w|
|00003c60| 69 6c 6c 20 6f 76 65 72 | 65 73 74 69 6d 61 74 65 |ill over|estimate|
|00003c70| 20 6c 75 6d 69 6e 61 6e | 63 65 2c 20 61 6e 64 0d | luminan|ce, and.|
|00003c80| 63 6f 6e 73 65 71 75 65 | 6e 74 6c 79 20 56 20 77 |conseque|ntly V w|
|00003c90| 69 6c 6c 20 62 65 20 74 | 6f 6f 20 6c 6f 77 2e 20 |ill be t|oo low. |
|00003ca0| 54 68 65 20 65 72 72 6f | 72 20 77 69 6c 6c 20 62 |The erro|r will b|
|00003cb0| 65 20 67 72 65 61 74 65 | 73 74 20 61 74 20 74 68 |e greate|st at th|
|00003cc0| 65 20 6d 69 64 64 6c 65 | 20 6f 66 20 65 61 63 68 |e middle| of each|
|00003cd0| 0d 6c 69 6e 65 61 72 6c | 79 20 69 6e 74 65 72 70 |.linearl|y interp|
|00003ce0| 6f 6c 61 74 65 64 20 56 | 20 69 6e 74 65 72 76 61 |olated V| interva|
|00003cf0| 6c 2e 0d 0d 49 66 20 74 | 68 65 20 72 65 71 75 65 |l...If t|he reque|
|00003d00| 73 74 65 64 20 56 20 69 | 6e 74 65 72 76 61 6c 20 |sted V i|nterval |
|00003d10| 69 73 20 6c 61 72 67 65 | 72 20 74 68 61 6e 20 4c |is large|r than L|
|00003d20| 49 4e 45 41 52 5f 56 5f | 44 4f 4d 41 49 4e 2c 20 |INEAR_V_|DOMAIN, |
|00003d30| 74 68 65 6e 20 69 74 20 | 69 73 20 73 70 6c 69 74 |then it |is split|
|00003d40| 0d 69 6e 74 6f 20 74 77 | 6f 20 69 6e 74 65 72 76 |.into tw|o interv|
|00003d50| 61 6c 73 20 62 79 20 6d | 61 6b 69 6e 67 20 61 20 |als by m|aking a |
|00003d60| 70 61 69 72 20 6f 66 20 | 72 65 63 75 72 73 69 76 |pair of |recursiv|
|00003d70| 65 20 63 61 6c 6c 73 2e | 20 4c 49 4e 45 41 52 5f |e calls.| LINEAR_|
|00003d80| 56 5f 44 4f 4d 41 49 4e | 20 69 73 0d 64 65 66 69 |V_DOMAIN| is.defi|
|00003d90| 6e 65 64 20 69 6e 20 4c | 75 6d 69 6e 61 6e 63 65 |ned in L|uminance|
|00003da0| 2e 68 2e 20 49 20 73 75 | 67 67 65 73 74 20 61 20 |.h. I su|ggest a |
|00003db0| 76 61 6c 75 65 20 6f 66 | 20 34 2c 20 62 75 74 20 |value of| 4, but |
|00003dc0| 69 74 20 6d 61 79 20 62 | 65 20 73 65 74 20 6c 61 |it may b|e set la|
|00003dd0| 72 67 65 72 20 74 6f 0d | 61 74 74 61 69 6e 20 73 |rger to.|attain s|
|00003de0| 6c 69 67 68 74 6c 79 20 | 68 69 67 68 65 72 20 73 |lightly |higher s|
|00003df0| 70 65 65 64 20 61 74 20 | 6c 6f 77 65 72 20 61 63 |peed at |lower ac|
|00003e00| 63 75 72 61 63 79 2e 0d | 0d 43 41 55 54 49 4f 4e |curacy..|.CAUTION|
|00003e10| 3a 20 54 68 69 73 20 72 | 6f 75 74 69 6e 65 20 69 |: This r|outine i|
|00003e20| 73 20 61 20 73 74 61 63 | 6b 20 68 6f 67 2e 20 45 |s a stac|k hog. E|
|00003e30| 61 63 68 20 63 61 6c 6c | 20 75 73 65 73 20 75 70 |ach call| uses up|
|00003e40| 20 61 62 6f 75 74 20 36 | 34 20 62 79 74 65 73 20 | about 6|4 bytes |
|00003e50| 6f 6e 20 74 68 65 0d 73 | 74 61 63 6b 2c 20 61 6e |on the.s|tack, an|
|00003e60| 64 20 69 74 20 63 61 6c | 6c 73 20 69 74 73 65 6c |d it cal|ls itsel|
|00003e70| 66 20 72 65 63 75 72 73 | 69 76 65 6c 79 2c 20 75 |f recurs|ively, u|
|00003e80| 70 20 74 6f 20 6c 6f 67 | 32 28 32 35 36 2f 4c 49 |p to log|2(256/LI|
|00003e90| 4e 45 41 52 5f 56 5f 44 | 4f 4d 41 49 4e 29 20 74 |NEAR_V_D|OMAIN) t|
|00003ea0| 69 6d 65 73 2e 0d 44 6f | 20 4e 4f 54 20 63 68 61 |imes..Do| NOT cha|
|00003eb0| 6e 67 65 20 61 6e 79 20 | 6f 66 20 74 68 65 20 64 |nge any |of the d|
|00003ec0| 65 63 6c 61 72 61 74 69 | 6f 6e 73 20 6f 66 20 74 |eclarati|ons of t|
|00003ed0| 68 65 20 22 6e 65 77 22 | 20 76 61 72 69 61 62 6c |he "new"| variabl|
|00003ee0| 65 73 20 75 73 65 64 20 | 69 6e 20 74 68 65 20 66 |es used |in the f|
|00003ef0| 69 72 73 74 0d 69 66 7b | 7d 20 74 6f 20 22 73 74 |irst.if{|} to "st|
|00003f00| 61 74 69 63 22 2c 20 61 | 73 20 74 68 61 74 20 77 |atic", a|s that w|
|00003f10| 6f 75 6c 64 20 63 61 75 | 73 65 20 74 68 65 20 72 |ould cau|se the r|
|00003f20| 65 63 75 72 73 69 6f 6e | 20 74 6f 20 66 61 69 6c |ecursion| to fail|
|00003f30| 2e 0d 2a 2f 0d 7b 0d 09 | 73 74 61 74 69 63 20 69 |..*/.{..|static i|
|00003f40| 6e 74 20 64 6f 4c 61 73 | 74 3d 31 3b 0d 09 69 6e |nt doLas|t=1;..in|
|00003f50| 74 20 73 61 76 65 44 6f | 4c 61 73 74 3b 0d 09 69 |t saveDo|Last;..i|
|00003f60| 6e 74 20 6e 65 77 4f 6e | 65 3b 0d 09 46 49 58 45 |nt newOn|e;..FIXE|
|00003f70| 44 20 5f 6e 65 77 4c 2c | 5f 6e 65 77 56 3b 0d 09 |D _newL,|_newV;..|
|00003f80| 72 65 67 69 73 74 65 72 | 20 6c 75 6d 69 6e 61 6e |register| luminan|
|00003f90| 63 65 52 65 63 6f 72 64 | 20 2a 4c 50 3d 4c 50 74 |ceRecord| *LP=LPt|
|00003fa0| 72 3b 0d 09 72 65 67 69 | 73 74 65 72 20 69 6e 74 |r;..regi|ster int|
|00003fb0| 20 69 2c 56 69 3b 0d 09 | 72 65 67 69 73 74 65 72 | i,Vi;..|register|
|00003fc0| 20 46 49 58 45 44 20 5f | 56 54 6f 47 6f 2c 5f 67 | FIXED _|VToGo,_g|
|00003fd0| 3b 0d 09 73 74 61 74 69 | 63 20 52 47 42 43 6f 6c |;..stati|c RGBCol|
|00003fe0| 6f 72 20 2a 52 47 42 50 | 74 72 3b 09 2f 2a 20 73 |or *RGBP|tr;./* s|
|00003ff0| 74 61 74 69 63 20 69 6e | 20 6f 72 64 65 72 20 74 |tatic in| order t|
|00004000| 6f 20 6d 69 6e 69 6d 69 | 7a 65 20 73 74 61 63 6b |o minimi|ze stack|
|00004010| 20 75 73 61 67 65 20 2a | 2f 0d 09 73 74 61 74 69 | usage *|/..stati|
|00004020| 63 20 69 6e 74 20 74 68 | 65 45 6e 74 72 79 3b 09 |c int th|eEntry;.|
|00004030| 09 2f 2a 20 73 74 61 74 | 69 63 20 69 6e 20 6f 72 |./* stat|ic in or|
|00004040| 64 65 72 20 74 6f 20 6d | 69 6e 69 6d 69 7a 65 20 |der to m|inimize |
|00004050| 73 74 61 63 6b 20 75 73 | 61 67 65 20 2a 2f 0d 09 |stack us|age */..|
|00004060| 73 74 61 74 69 63 20 46 | 49 58 45 44 20 5f 56 2c |static F|IXED _V,|
|00004070| 5f 64 56 3b 09 09 2f 2a | 20 73 74 61 74 69 63 20 |_dV;../*| static |
|00004080| 69 6e 20 6f 72 64 65 72 | 20 74 6f 20 6d 69 6e 69 |in order| to mini|
|00004090| 6d 69 7a 65 20 73 74 61 | 63 6b 20 75 73 61 67 65 |mize sta|ck usage|
|000040a0| 20 2a 2f 0d 09 72 65 67 | 69 73 74 65 72 20 73 68 | */..reg|ister sh|
|000040b0| 6f 72 74 20 6c 65 66 74 | 53 68 69 66 74 3b 0d 09 |ort left|Shift;..|
|000040c0| 0d 09 69 66 28 6c 61 73 | 74 2d 66 69 72 73 74 3e |..if(las|t-first>|
|000040d0| 31 20 29 7b 0d 09 09 5f | 64 56 3d 5f 6c 61 73 74 |1 ){..._|dV=_last|
|000040e0| 56 2d 5f 66 69 72 73 74 | 56 3b 0d 09 09 69 66 28 |V-_first|V;...if(|
|000040f0| 5f 64 56 3e 4c 6f 6e 67 | 54 6f 46 69 78 28 4c 49 |_dV>Long|ToFix(LI|
|00004100| 4e 45 41 52 5f 56 5f 44 | 4f 4d 41 49 4e 29 20 7c |NEAR_V_D|OMAIN) ||
|00004110| 7c 20 5f 64 56 3c 4c 6f | 6e 67 54 6f 46 69 78 28 || _dV<Lo|ngToFix(|
|00004120| 2d 4c 49 4e 45 41 52 5f | 56 5f 44 4f 4d 41 49 4e |-LINEAR_|V_DOMAIN|
|00004130| 29 29 7b 0d 09 09 09 6e | 65 77 4f 6e 65 3d 28 66 |)){....n|ewOne=(f|
|00004140| 69 72 73 74 2b 6c 61 73 | 74 29 3e 3e 31 3b 0d 09 |irst+las|t)>>1;..|
|00004150| 09 09 23 69 66 20 46 41 | 53 54 5f 4c 55 4d 49 4e |..#if FA|ST_LUMIN|
|00004160| 41 4e 43 45 0d 09 09 09 | 09 5f 6e 65 77 4c 3d 5f |ANCE....|._newL=_|
|00004170| 66 69 72 73 74 4c 2b 28 | 28 6e 65 77 4f 6e 65 2d |firstL+(|(newOne-|
|00004180| 66 69 72 73 74 29 2a 5f | 64 4c 36 34 3e 3e 36 29 |first)*_|dL64>>6)|
|00004190| 3b 0d 09 09 09 23 65 6c | 73 65 0d 09 09 09 09 5f |;....#el|se....._|
|000041a0| 6e 65 77 4c 3d 5f 66 69 | 72 73 74 4c 2b 28 6e 65 |newL=_fi|rstL+(ne|
|000041b0| 77 4f 6e 65 2d 66 69 72 | 73 74 29 2a 5f 64 4c 36 |wOne-fir|st)*_dL6|
|000041c0| 34 3b 0d 09 09 09 23 65 | 6e 64 69 66 0d 09 09 09 |4;....#e|ndif....|
|000041d0| 5f 6e 65 77 56 3d 5f 4c | 54 6f 56 28 4c 50 2c 5f |_newV=_L|ToV(LP,_|
|000041e0| 6e 65 77 4c 20 2b 20 4c | 50 2d 3e 5f 4c 4f 66 66 |newL + L|P->_LOff|
|000041f0| 73 65 74 29 3b 0d 09 09 | 09 73 61 76 65 44 6f 4c |set);...|.saveDoL|
|00004200| 61 73 74 3d 64 6f 4c 61 | 73 74 3b 0d 09 09 09 64 |ast=doLa|st;....d|
|00004210| 6f 4c 61 73 74 3d 30 3b | 0d 09 09 09 5f 53 65 74 |oLast=0;|...._Set|
|00004220| 4c 75 6d 69 6e 61 6e 63 | 65 73 28 4c 50 2c 66 69 |Luminanc|es(LP,fi|
|00004230| 72 73 74 2c 6e 65 77 4f | 6e 65 2c 5f 66 69 72 73 |rst,newO|ne,_firs|
|00004240| 74 4c 2c 5f 64 4c 36 34 | 2c 5f 66 69 72 73 74 56 |tL,_dL64|,_firstV|
|00004250| 2c 5f 6e 65 77 56 29 3b | 0d 09 09 09 64 6f 4c 61 |,_newV);|....doLa|
|00004260| 73 74 3d 73 61 76 65 44 | 6f 4c 61 73 74 3b 0d 09 |st=saveD|oLast;..|
|00004270| 09 09 5f 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 73 |.._SetLu|minances|
|00004280| 28 4c 50 2c 6e 65 77 4f | 6e 65 2c 6c 61 73 74 2c |(LP,newO|ne,last,|
|00004290| 5f 6e 65 77 4c 2c 5f 64 | 4c 36 34 2c 5f 6e 65 77 |_newL,_d|L64,_new|
|000042a0| 56 2c 5f 6c 61 73 74 56 | 29 3b 0d 09 09 09 72 65 |V,_lastV|);....re|
|000042b0| 74 75 72 6e 3b 0d 09 09 | 7d 0d 09 7d 0d 09 69 66 |turn;...|}..}..if|
|000042c0| 28 6c 61 73 74 21 3d 66 | 69 72 73 74 29 5f 64 56 |(last!=f|irst)_dV|
|000042d0| 3d 28 5f 6c 61 73 74 56 | 2d 5f 66 69 72 73 74 56 |=(_lastV|-_firstV|
|000042e0| 29 2f 28 6c 61 73 74 2d | 66 69 72 73 74 29 3b 0d |)/(last-|first);.|
|000042f0| 09 65 6c 73 65 20 5f 64 | 56 3d 30 3b 0d 09 69 66 |.else _d|V=0;..if|
|00004300| 28 21 64 6f 4c 61 73 74 | 29 6c 61 73 74 2d 2d 3b |(!doLast|)last--;|
|00004310| 0d 09 6c 65 66 74 53 68 | 69 66 74 3d 4c 50 2d 3e |..leftSh|ift=LP->|
|00004320| 6c 65 66 74 53 68 69 66 | 74 3b 0d 09 66 6f 72 28 |leftShif|t;..for(|
|00004330| 74 68 65 45 6e 74 72 79 | 3d 66 69 72 73 74 2c 5f |theEntry|=first,_|
|00004340| 56 3d 5f 66 69 72 73 74 | 56 3b 74 68 65 45 6e 74 |V=_first|V;theEnt|
|00004350| 72 79 3c 3d 6c 61 73 74 | 3b 74 68 65 45 6e 74 72 |ry<=last|;theEntr|
|00004360| 79 2b 2b 2c 5f 56 2b 3d | 5f 64 56 29 7b 0d 09 09 |y++,_V+=|_dV){...|
|00004370| 2f 2a 2a 2a 2a 2a 2a 20 | 54 68 69 73 20 73 65 63 |/****** |This sec|
|00004380| 74 69 6f 6e 20 6f 66 20 | 63 6f 64 65 20 69 73 20 |tion of |code is |
|00004390| 63 6f 70 69 65 64 20 66 | 72 6f 6d 20 5f 53 65 74 |copied f|rom _Set|
|000043a0| 4c 75 6d 69 6e 61 6e 63 | 65 28 29 20 2a 2a 2a 2a |Luminanc|e() ****|
|000043b0| 2f 0d 09 09 52 47 42 50 | 74 72 20 3d 20 26 4c 50 |/...RGBP|tr = &LP|
|000043c0| 2d 3e 74 61 62 6c 65 5b | 74 68 65 45 6e 74 72 79 |->table[|theEntry|
|000043d0| 5d 2e 72 67 62 3b 0d 09 | 09 2a 52 47 42 50 74 72 |].rgb;..|.*RGBPtr|
|000043e0| 3d 4c 50 2d 3e 72 67 62 | 3b 09 09 09 09 09 09 2f |=LP->rgb|;....../|
|000043f0| 2a 20 6c 6f 61 64 20 66 | 6f 72 20 66 69 78 65 64 |* load f|or fixed|
|00004400| 20 44 41 43 73 20 2a 2f | 0d 09 09 5f 56 54 6f 47 | DACs */|..._VToG|
|00004410| 6f 3d 5f 56 20 2d 20 4c | 50 2d 3e 5f 56 46 69 78 |o=_V - L|P->_VFix|
|00004420| 65 64 20 2b 20 4c 50 2d | 3e 5f 56 48 61 6c 66 53 |ed + LP-|>_VHalfS|
|00004430| 74 65 70 3b 0d 09 09 66 | 6f 72 28 69 3d 4c 50 2d |tep;...f|or(i=LP-|
|00004440| 3e 66 69 78 65 64 3b 69 | 3c 4c 50 2d 3e 64 61 63 |>fixed;i|<LP->dac|
|00004450| 73 3b 69 2b 2b 29 20 7b | 0d 09 09 09 5f 67 3d 4c |s;i++) {|...._g=L|
|00004460| 50 2d 3e 5f 67 61 69 6e | 5b 69 5d 3b 0d 09 09 09 |P->_gain|[i];....|
|00004470| 56 69 3d 5f 56 54 6f 47 | 6f 2f 5f 67 3b 09 09 09 |Vi=_VToG|o/_g;...|
|00004480| 09 09 09 2f 2a 20 74 72 | 75 6e 63 61 74 65 20 74 |.../* tr|uncate t|
|00004490| 6f 20 69 6e 74 65 67 65 | 72 20 2a 2f 0d 09 09 09 |o intege|r */....|
|000044a0| 69 66 28 56 69 3e 4c 50 | 2d 3e 56 4d 61 78 29 56 |if(Vi>LP|->VMax)V|
|000044b0| 69 3d 4c 50 2d 3e 56 4d | 61 78 3b 0d 09 09 09 69 |i=LP->VM|ax;....i|
|000044c0| 66 28 56 69 3c 4c 50 2d | 3e 56 4d 69 6e 29 56 69 |f(Vi<LP-|>VMin)Vi|
|000044d0| 3d 4c 50 2d 3e 56 4d 69 | 6e 3b 0d 09 09 09 5f 56 |=LP->VMi|n;...._V|
|000044e0| 54 6f 47 6f 20 2d 3d 20 | 56 69 2a 5f 67 3b 0d 09 |ToGo -= |Vi*_g;..|
|000044f0| 09 09 28 28 73 68 6f 72 | 74 20 2a 29 52 47 42 50 |..((shor|t *)RGBP|
|00004500| 74 72 29 5b 4c 50 2d 3e | 64 61 63 5b 69 5d 5d 3d |tr)[LP->|dac[i]]=|
|00004510| 56 69 3c 3c 6c 65 66 74 | 53 68 69 66 74 3b 0d 09 |Vi<<left|Shift;..|
|00004520| 09 7d 0d 09 09 2f 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |.}.../**|********|
|00004530| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004540| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004550| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004560| 2a 2a 2a 2a 2a 2f 0d 09 | 7d 0d 09 72 65 74 75 72 |*****/..|}..retur|
|00004570| 6e 3b 0d 7d 0d 0d 76 6f | 69 64 20 5f 53 65 74 4c |n;.}..vo|id _SetL|
|00004580| 75 6d 69 6e 61 6e 63 65 | 28 6c 75 6d 69 6e 61 6e |uminance|(luminan|
|00004590| 63 65 52 65 63 6f 72 64 | 20 2a 4c 50 74 72 2c 69 |ceRecord| *LPtr,i|
|000045a0| 6e 74 20 74 68 65 45 6e | 74 72 79 2c 46 49 58 45 |nt theEn|try,FIXE|
|000045b0| 44 20 5f 6c 75 6d 69 6e | 61 6e 63 65 29 0d 2f 2a |D _lumin|ance)./*|
|000045c0| 0d 53 65 74 20 6f 6e 65 | 20 65 6e 74 72 79 20 69 |.Set one| entry i|
|000045d0| 6e 20 74 68 65 20 43 6f | 6c 6f 72 53 70 65 63 20 |n the Co|lorSpec |
|000045e0| 74 61 62 6c 65 20 74 6f | 20 61 20 73 70 65 63 69 |table to| a speci|
|000045f0| 66 69 65 64 20 6c 75 6d | 69 6e 61 6e 63 65 2e 20 |fied lum|inance. |
|00004600| 54 68 69 73 20 69 73 20 | 74 68 65 0d 70 72 69 76 |This is |the.priv|
|00004610| 61 74 65 20 73 75 62 72 | 6f 75 74 69 6e 65 20 74 |ate subr|outine t|
|00004620| 68 61 74 20 61 63 74 75 | 61 6c 6c 79 20 64 6f 65 |hat actu|ally doe|
|00004630| 73 20 61 6c 6c 20 74 68 | 65 20 77 6f 72 6b 20 66 |s all th|e work f|
|00004640| 6f 72 20 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 28 |or SetLu|minance(|
|00004650| 29 2e 20 54 68 69 73 0d | 72 6f 75 74 69 6e 65 20 |). This.|routine |
|00004660| 69 73 20 64 65 73 69 67 | 6e 65 64 20 74 6f 20 72 |is desig|ned to r|
|00004670| 75 6e 20 61 73 20 66 61 | 73 74 20 61 73 20 70 6f |un as fa|st as po|
|00004680| 73 73 69 62 6c 65 2e 0d | 2a 2f 0d 7b 0d 09 72 65 |ssible..|*/.{..re|
|00004690| 67 69 73 74 65 72 20 6c | 75 6d 69 6e 61 6e 63 65 |gister l|uminance|
|000046a0| 52 65 63 6f 72 64 20 2a | 4c 50 3d 4c 50 74 72 3b |Record *|LP=LPtr;|
|000046b0| 0d 09 72 65 67 69 73 74 | 65 72 20 69 6e 74 20 69 |..regist|er int i|
|000046c0| 2c 56 69 3b 0d 09 72 65 | 67 69 73 74 65 72 20 46 |,Vi;..re|gister F|
|000046d0| 49 58 45 44 20 5f 56 54 | 6f 47 6f 2c 5f 67 3b 0d |IXED _VT|oGo,_g;.|
|000046e0| 09 52 47 42 43 6f 6c 6f | 72 20 2a 52 47 42 50 74 |.RGBColo|r *RGBPt|
|000046f0| 72 3b 0d 09 72 65 67 69 | 73 74 65 72 20 73 68 6f |r;..regi|ster sho|
|00004700| 72 74 20 6c 65 66 74 53 | 68 69 66 74 3d 4c 50 2d |rt leftS|hift=LP-|
|00004710| 3e 6c 65 66 74 53 68 69 | 66 74 3b 0d 09 0d 09 52 |>leftShi|ft;....R|
|00004720| 47 42 50 74 72 20 3d 20 | 26 4c 50 2d 3e 74 61 62 |GBPtr = |&LP->tab|
|00004730| 6c 65 5b 74 68 65 45 6e | 74 72 79 5d 2e 72 67 62 |le[theEn|try].rgb|
|00004740| 3b 0d 09 2a 52 47 42 50 | 74 72 3d 4c 50 2d 3e 72 |;..*RGBP|tr=LP->r|
|00004750| 67 62 3b 09 09 09 09 09 | 09 2f 2a 20 6c 6f 61 64 |gb;.....|./* load|
|00004760| 20 66 6f 72 20 66 69 78 | 65 64 20 44 41 43 73 20 | for fix|ed DACs |
|00004770| 2a 2f 0d 09 5f 56 54 6f | 47 6f 3d 5f 4c 54 6f 56 |*/.._VTo|Go=_LToV|
|00004780| 28 4c 50 2c 5f 6c 75 6d | 69 6e 61 6e 63 65 20 2b |(LP,_lum|inance +|
|00004790| 20 4c 50 2d 3e 5f 4c 4f | 66 66 73 65 74 29 20 2d | LP->_LO|ffset) -|
|000047a0| 20 4c 50 2d 3e 5f 56 46 | 69 78 65 64 20 2b 20 4c | LP->_VF|ixed + L|
|000047b0| 50 2d 3e 5f 56 48 61 6c | 66 53 74 65 70 3b 0d 09 |P->_VHal|fStep;..|
|000047c0| 66 6f 72 28 69 3d 4c 50 | 2d 3e 66 69 78 65 64 3b |for(i=LP|->fixed;|
|000047d0| 69 3c 4c 50 2d 3e 64 61 | 63 73 3b 69 2b 2b 29 20 |i<LP->da|cs;i++) |
|000047e0| 7b 0d 09 09 5f 67 3d 4c | 50 2d 3e 5f 67 61 69 6e |{..._g=L|P->_gain|
|000047f0| 5b 69 5d 3b 0d 09 09 56 | 69 3d 5f 56 54 6f 47 6f |[i];...V|i=_VToGo|
|00004800| 2f 5f 67 3b 09 09 09 09 | 09 09 2f 2a 20 74 72 75 |/_g;....|../* tru|
|00004810| 6e 63 61 74 65 20 74 6f | 20 69 6e 74 65 67 65 72 |ncate to| integer|
|00004820| 20 2a 2f 0d 09 09 69 66 | 28 56 69 3e 4c 50 2d 3e | */...if|(Vi>LP->|
|00004830| 56 4d 61 78 29 56 69 3d | 4c 50 2d 3e 56 4d 61 78 |VMax)Vi=|LP->VMax|
|00004840| 3b 0d 09 09 69 66 28 56 | 69 3c 4c 50 2d 3e 56 4d |;...if(V|i<LP->VM|
|00004850| 69 6e 29 56 69 3d 4c 50 | 2d 3e 56 4d 69 6e 3b 0d |in)Vi=LP|->VMin;.|
|00004860| 09 09 5f 56 54 6f 47 6f | 20 2d 3d 20 56 69 2a 5f |.._VToGo| -= Vi*_|
|00004870| 67 3b 0d 09 09 28 28 73 | 68 6f 72 74 20 2a 29 52 |g;...((s|hort *)R|
|00004880| 47 42 50 74 72 29 5b 4c | 50 2d 3e 64 61 63 5b 69 |GBPtr)[L|P->dac[i|
|00004890| 5d 5d 3d 56 69 3c 3c 6c | 65 66 74 53 68 69 66 74 |]]=Vi<<l|eftShift|
|000048a0| 3b 0d 09 7d 0d 7d 0d 0d | 76 6f 69 64 20 49 6e 63 |;..}.}..|void Inc|
|000048b0| 72 65 6d 65 6e 74 4c 75 | 6d 69 6e 61 6e 63 65 28 |rementLu|minance(|
|000048c0| 47 44 48 61 6e 64 6c 65 | 20 64 65 76 69 63 65 2c |GDHandle| device,|
|000048d0| 6c 75 6d 69 6e 61 6e 63 | 65 52 65 63 6f 72 64 20 |luminanc|eRecord |
|000048e0| 2a 4c 50 74 72 2c 69 6e | 74 20 74 68 65 45 6e 74 |*LPtr,in|t theEnt|
|000048f0| 72 79 29 0d 2f 2a 0d 4d | 61 6b 65 20 73 6d 61 6c |ry)./*.M|ake smal|
|00004900| 6c 65 73 74 20 70 6f 73 | 73 69 62 6c 65 20 69 6e |lest pos|sible in|
|00004910| 63 72 65 61 73 65 20 6f | 66 20 74 68 65 20 6c 75 |crease o|f the lu|
|00004920| 6d 69 6e 61 6e 63 65 20 | 6f 66 20 6f 6e 65 20 65 |minance |of one e|
|00004930| 6e 74 72 79 20 69 6e 20 | 74 68 65 20 43 6f 6c 6f |ntry in |the Colo|
|00004940| 72 53 70 65 63 0d 74 61 | 62 6c 65 2e 0d 2a 2f 0d |rSpec.ta|ble..*/.|
|00004950| 7b 0d 09 64 6f 75 62 6c | 65 20 56 3b 0d 09 72 65 |{..doubl|e V;..re|
|00004960| 67 69 73 74 65 72 20 6c | 75 6d 69 6e 61 6e 63 65 |gister l|uminance|
|00004970| 52 65 63 6f 72 64 20 2a | 4c 50 3d 4c 50 74 72 3b |Record *|LP=LPtr;|
|00004980| 0d 09 0d 09 56 3d 47 65 | 74 56 28 64 65 76 69 63 |....V=Ge|tV(devic|
|00004990| 65 2c 4c 50 2c 74 68 65 | 45 6e 74 72 79 29 3b 0d |e,LP,the|Entry);.|
|000049a0| 09 56 2b 3d 4c 50 2d 3e | 56 48 61 6c 66 53 74 65 |.V+=LP->|VHalfSte|
|000049b0| 70 3b 0d 09 56 2b 3d 4c | 50 2d 3e 56 48 61 6c 66 |p;..V+=L|P->VHalf|
|000049c0| 53 74 65 70 3b 0d 09 53 | 65 74 4c 75 6d 69 6e 61 |Step;..S|etLumina|
|000049d0| 6e 63 65 28 64 65 76 69 | 63 65 2c 4c 50 2c 74 68 |nce(devi|ce,LP,th|
|000049e0| 65 45 6e 74 72 79 2c 56 | 54 6f 4c 28 4c 50 2c 56 |eEntry,V|ToL(LP,V|
|000049f0| 29 2c 4c 50 2d 3e 6c 6f | 77 4c 75 6d 69 6e 61 6e |),LP->lo|wLuminan|
|00004a00| 63 65 2c 4c 50 2d 3e 68 | 69 67 68 4c 75 6d 69 6e |ce,LP->h|ighLumin|
|00004a10| 61 6e 63 65 29 3b 0d 7d | 0d 0d 46 49 58 45 44 20 |ance);.}|..FIXED |
|00004a20| 5f 54 6f 6c 65 72 61 6e | 63 65 28 6c 75 6d 69 6e |_Toleran|ce(lumin|
|00004a30| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 74 72 |anceReco|rd *LPtr|
|00004a40| 2c 46 49 58 45 44 20 5f | 6c 75 6d 69 6e 61 6e 63 |,FIXED _|luminanc|
|00004a50| 65 29 0d 7b 0d 09 72 65 | 67 69 73 74 65 72 20 6c |e).{..re|gister l|
|00004a60| 75 6d 69 6e 61 6e 63 65 | 52 65 63 6f 72 64 20 2a |uminance|Record *|
|00004a70| 4c 50 3d 4c 50 74 72 3b | 0d 09 72 65 67 69 73 74 |LP=LPtr;|..regist|
|00004a80| 65 72 20 46 49 58 45 44 | 20 5f 74 6f 6c 65 72 61 |er FIXED| _tolera|
|00004a90| 6e 63 65 2c 5f 74 3b 0d | 09 0d 09 2f 2a 20 71 75 |nce,_t;.|.../* qu|
|00004aa0| 69 63 6b 20 61 6e 64 20 | 64 69 72 74 79 20 65 73 |ick and |dirty es|
|00004ab0| 74 69 6d 61 74 65 20 6f | 66 20 74 6f 6c 65 72 61 |timate o|f tolera|
|00004ac0| 6e 63 65 20 2a 2f 0d 09 | 69 66 28 4c 50 2d 3e 4c |nce */..|if(LP->L|
|00004ad0| 2e 65 78 69 73 74 73 3d | 3d 6c 75 6d 69 6e 61 6e |.exists=|=luminan|
|00004ae0| 63 65 53 65 74 29 7b 0d | 09 09 5f 74 6f 6c 65 72 |ceSet){.|.._toler|
|00004af0| 61 6e 63 65 3d 4c 50 2d | 3e 4c 2e 5f 4c 5b 30 5d |ance=LP-|>L._L[0]|
|00004b00| 20 2d 20 5f 6c 75 6d 69 | 6e 61 6e 63 65 3b 0d 09 | - _lumi|nance;..|
|00004b10| 09 5f 74 3d 5f 6c 75 6d | 69 6e 61 6e 63 65 20 2d |._t=_lum|inance -|
|00004b20| 20 4c 50 2d 3e 4c 2e 5f | 4c 5b 4c 55 4d 49 4e 41 | LP->L._|L[LUMINA|
|00004b30| 4e 43 45 53 5f 49 4e 5f | 54 41 42 4c 45 2d 31 5d |NCES_IN_|TABLE-1]|
|00004b40| 3b 0d 09 09 69 66 28 5f | 74 6f 6c 65 72 61 6e 63 |;...if(_|toleranc|
|00004b50| 65 3c 5f 74 29 5f 74 6f | 6c 65 72 61 6e 63 65 3d |e<_t)_to|lerance=|
|00004b60| 5f 74 3b 0d 09 09 69 66 | 28 5f 74 6f 6c 65 72 61 |_t;...if|(_tolera|
|00004b70| 6e 63 65 3c 30 29 5f 74 | 6f 6c 65 72 61 6e 63 65 |nce<0)_t|olerance|
|00004b80| 3d 30 3b 0d 09 09 5f 74 | 6f 6c 65 72 61 6e 63 65 |=0;..._t|olerance|
|00004b90| 2b 3d 4c 50 2d 3e 5f 74 | 6f 6c 65 72 61 6e 63 65 |+=LP->_t|olerance|
|00004ba0| 3b 0d 09 7d 0d 09 65 6c | 73 65 20 5f 74 6f 6c 65 |;..}..el|se _tole|
|00004bb0| 72 61 6e 63 65 3d 4c 50 | 2d 3e 5f 74 6f 6c 65 72 |rance=LP|->_toler|
|00004bc0| 61 6e 63 65 3b 0d 09 72 | 65 74 75 72 6e 20 5f 74 |ance;..r|eturn _t|
|00004bd0| 6f 6c 65 72 61 6e 63 65 | 3b 0d 7d 0d 0d 64 6f 75 |olerance|;.}..dou|
|00004be0| 62 6c 65 20 47 65 74 4c | 75 6d 69 6e 61 6e 63 65 |ble GetL|uminance|
|00004bf0| 28 47 44 48 61 6e 64 6c | 65 20 64 65 76 69 63 65 |(GDHandl|e device|
|00004c00| 2c 6c 75 6d 69 6e 61 6e | 63 65 52 65 63 6f 72 64 |,luminan|ceRecord|
|00004c10| 20 2a 4c 50 2c 69 6e 74 | 20 74 68 65 45 6e 74 72 | *LP,int| theEntr|
|00004c20| 79 29 0d 2f 2a 0d 49 66 | 20 64 65 76 69 63 65 20 |y)./*.If| device |
|00004c30| 69 73 20 6e 6f 74 20 4e | 55 4c 4c 20 74 68 65 6e |is not N|ULL then|
|00004c40| 20 65 78 61 6d 69 6e 65 | 73 20 6f 6e 65 20 65 6e | examine|s one en|
|00004c50| 74 72 79 20 69 6e 20 74 | 68 65 20 61 63 74 75 61 |try in t|he actua|
|00004c60| 6c 20 63 6c 75 74 2c 20 | 6f 74 68 65 72 77 69 73 |l clut, |otherwis|
|00004c70| 65 0d 65 78 61 6d 69 6e | 65 73 20 74 68 65 20 43 |e.examin|es the C|
|00004c80| 6f 6c 6f 72 53 70 65 63 | 20 74 61 62 6c 65 20 63 |olorSpec| table c|
|00004c90| 6f 6e 74 61 69 6e 65 64 | 20 69 6e 20 2a 4c 50 2c |ontained| in *LP,|
|00004ca0| 20 61 6e 64 20 69 6e 20 | 65 69 74 68 65 72 20 63 | and in |either c|
|00004cb0| 61 73 65 20 72 65 74 75 | 72 6e 73 20 74 68 65 0d |ase retu|rns the.|
|00004cc0| 6c 75 6d 69 6e 61 6e 63 | 65 20 74 68 61 74 20 77 |luminanc|e that w|
|00004cd0| 69 6c 6c 20 62 65 20 70 | 72 6f 64 75 63 65 64 2e |ill be p|roduced.|
|00004ce0| 20 53 75 70 70 6c 79 69 | 6e 67 20 61 6e 20 69 6c | Supplyi|ng an il|
|00004cf0| 6c 65 67 61 6c 20 65 6e | 74 72 79 20 76 61 6c 75 |legal en|try valu|
|00004d00| 65 20 72 65 73 75 6c 74 | 73 20 69 6e 20 61 0d 72 |e result|s in a.r|
|00004d10| 65 74 75 72 6e 65 64 20 | 76 61 6c 75 65 20 6f 66 |eturned |value of|
|00004d20| 20 2d 49 4e 46 2e 0d 2a | 2f 0d 7b 0d 09 72 65 74 | -INF..*|/.{..ret|
|00004d30| 75 72 6e 20 56 54 6f 4c | 28 4c 50 2c 47 65 74 56 |urn VToL|(LP,GetV|
|00004d40| 28 64 65 76 69 63 65 2c | 4c 50 2c 74 68 65 45 6e |(device,|LP,theEn|
|00004d50| 74 72 79 29 29 3b 0d 7d | 0d 0d 64 6f 75 62 6c 65 |try));.}|..double|
|00004d60| 20 47 65 74 56 28 47 44 | 48 61 6e 64 6c 65 20 64 | GetV(GD|Handle d|
|00004d70| 65 76 69 63 65 2c 6c 75 | 6d 69 6e 61 6e 63 65 52 |evice,lu|minanceR|
|00004d80| 65 63 6f 72 64 20 2a 4c | 50 2c 69 6e 74 20 74 68 |ecord *L|P,int th|
|00004d90| 65 45 6e 74 72 79 29 0d | 2f 2a 0d 49 66 20 64 65 |eEntry).|/*.If de|
|00004da0| 76 69 63 65 20 69 73 20 | 6e 6f 74 20 4e 55 4c 4c |vice is |not NULL|
|00004db0| 20 74 68 65 6e 20 65 78 | 61 6d 69 6e 65 73 20 6f | then ex|amines o|
|00004dc0| 6e 65 20 65 6e 74 72 79 | 20 69 6e 20 74 68 65 20 |ne entry| in the |
|00004dd0| 61 63 74 75 61 6c 20 63 | 6c 75 74 2c 20 6f 74 68 |actual c|lut, oth|
|00004de0| 65 72 77 69 73 65 0d 65 | 78 61 6d 69 6e 65 73 20 |erwise.e|xamines |
|00004df0| 74 68 65 20 43 6f 6c 6f | 72 53 70 65 63 20 74 61 |the Colo|rSpec ta|
|00004e00| 62 6c 65 20 63 6f 6e 74 | 61 69 6e 65 64 20 69 6e |ble cont|ained in|
|00004e10| 20 2a 4c 50 2c 20 61 6e | 64 20 69 6e 20 65 69 74 | *LP, an|d in eit|
|00004e20| 68 65 72 20 63 61 73 65 | 20 72 65 74 75 72 6e 73 |her case| returns|
|00004e30| 20 74 68 65 20 56 0d 74 | 68 61 74 20 77 69 6c 6c | the V.t|hat will|
|00004e40| 20 62 65 20 70 72 6f 64 | 75 63 65 64 2e 20 53 75 | be prod|uced. Su|
|00004e50| 70 70 6c 79 69 6e 67 20 | 61 6e 20 69 6c 6c 65 67 |pplying |an illeg|
|00004e60| 61 6c 20 65 6e 74 72 79 | 20 76 61 6c 75 65 20 72 |al entry| value r|
|00004e70| 65 73 75 6c 74 73 20 69 | 6e 20 61 20 72 65 74 75 |esults i|n a retu|
|00004e80| 72 6e 65 64 0d 76 61 6c | 75 65 20 6f 66 20 2d 49 |rned.val|ue of -I|
|00004e90| 4e 46 2e 0d 2a 2f 0d 7b | 0d 09 52 47 42 43 6f 6c |NF..*/.{|..RGBCol|
|00004ea0| 6f 72 20 2a 6d 79 52 47 | 42 50 74 72 3d 4e 55 4c |or *myRG|BPtr=NUL|
|00004eb0| 4c 3b 0d 09 43 6f 6c 6f | 72 53 70 65 63 20 6d 79 |L;..Colo|rSpec my|
|00004ec0| 43 53 70 65 63 3b 0d 09 | 64 6f 75 62 6c 65 20 56 |CSpec;..|double V|
|00004ed0| 3b 0d 09 69 6e 74 20 65 | 72 72 6f 72 3b 0d 09 0d |;..int e|rror;...|
|00004ee0| 09 69 66 28 64 65 76 69 | 63 65 20 21 3d 20 4e 55 |.if(devi|ce != NU|
|00004ef0| 4c 4c 29 20 7b 0d 09 09 | 69 66 28 74 68 65 45 6e |LL) {...|if(theEn|
|00004f00| 74 72 79 3c 30 20 7c 7c | 20 74 68 65 45 6e 74 72 |try<0 ||| theEntr|
|00004f10| 79 3e 3d 47 44 43 4f 4c | 4f 52 53 28 64 65 76 69 |y>=GDCOL|ORS(devi|
|00004f20| 63 65 29 29 7b 0d 09 09 | 09 50 72 69 6e 74 66 45 |ce)){...|.PrintfE|
|00004f30| 78 69 74 28 22 47 65 74 | 4c 75 6d 69 6e 61 6e 63 |xit("Get|Luminanc|
|00004f40| 65 3a 20 69 6c 6c 65 67 | 61 6c 20 65 6e 74 72 79 |e: illeg|al entry|
|00004f50| 20 25 64 5c 6e 22 2c 74 | 68 65 45 6e 74 72 79 29 | %d\n",t|heEntry)|
|00004f60| 3b 0d 09 09 7d 0d 09 09 | 65 72 72 6f 72 3d 47 44 |;...}...|error=GD|
|00004f70| 47 65 74 45 6e 74 72 69 | 65 73 28 64 65 76 69 63 |GetEntri|es(devic|
|00004f80| 65 2c 74 68 65 45 6e 74 | 72 79 2c 30 2c 26 6d 79 |e,theEnt|ry,0,&my|
|00004f90| 43 53 70 65 63 29 3b 0d | 09 09 69 66 28 65 72 72 |CSpec);.|..if(err|
|00004fa0| 6f 72 29 7b 0d 09 09 09 | 50 72 69 6e 74 66 45 78 |or){....|PrintfEx|
|00004fb0| 69 74 28 22 47 65 74 4c | 75 6d 69 6e 61 6e 63 65 |it("GetL|uminance|
|00004fc0| 3a 20 47 44 47 65 74 45 | 6e 74 72 69 65 73 20 65 |: GDGetE|ntries e|
|00004fd0| 72 72 6f 72 20 25 64 5c | 30 30 37 22 2c 65 72 72 |rror %d\|007",err|
|00004fe0| 6f 72 29 3b 0d 09 09 7d | 0d 09 09 6d 79 52 47 42 |or);...}|...myRGB|
|00004ff0| 50 74 72 3d 26 6d 79 43 | 53 70 65 63 2e 72 67 62 |Ptr=&myC|Spec.rgb|
|00005000| 3b 0d 09 7d 0d 09 65 6c | 73 65 20 7b 0d 09 09 69 |;..}..el|se {...i|
|00005010| 66 28 4c 50 21 3d 4e 55 | 4c 4c 20 26 26 20 74 68 |f(LP!=NU|LL && th|
|00005020| 65 45 6e 74 72 79 3e 3d | 30 20 26 26 20 74 68 65 |eEntry>=|0 && the|
|00005030| 45 6e 74 72 79 3c 43 4f | 4c 4f 52 53 29 20 0d 09 |Entry<CO|LORS) ..|
|00005040| 09 09 6d 79 52 47 42 50 | 74 72 3d 26 4c 50 2d 3e |..myRGBP|tr=&LP->|
|00005050| 74 61 62 6c 65 5b 74 68 | 65 45 6e 74 72 79 5d 2e |table[th|eEntry].|
|00005060| 72 67 62 3b 0d 09 7d 0d | 09 69 66 28 6d 79 52 47 |rgb;..}.|.if(myRG|
|00005070| 42 50 74 72 20 3d 3d 20 | 4e 55 4c 4c 29 20 72 65 |BPtr == |NULL) re|
|00005080| 74 75 72 6e 20 2d 49 4e | 46 3b 0d 09 56 20 3d 20 |turn -IN|F;..V = |
|00005090| 4c 50 2d 3e 72 2a 28 6d | 79 52 47 42 50 74 72 2d |LP->r*(m|yRGBPtr-|
|000050a0| 3e 72 65 64 3e 3e 38 29 | 3b 0d 09 56 20 2b 3d 20 |>red>>8)|;..V += |
|000050b0| 4c 50 2d 3e 67 2a 28 6d | 79 52 47 42 50 74 72 2d |LP->g*(m|yRGBPtr-|
|000050c0| 3e 67 72 65 65 6e 3e 3e | 38 29 3b 0d 09 56 20 2b |>green>>|8);..V +|
|000050d0| 3d 20 4c 50 2d 3e 62 2a | 28 6d 79 52 47 42 50 74 |= LP->b*|(myRGBPt|
|000050e0| 72 2d 3e 62 6c 75 65 3e | 3e 38 29 3b 0d 09 72 65 |r->blue>|>8);..re|
|000050f0| 74 75 72 6e 20 56 3b 0d | 7d 0d 0d 76 6f 69 64 20 |turn V;.|}..void |
|00005100| 4c 6f 61 64 4c 75 6d 69 | 6e 61 6e 63 65 73 28 47 |LoadLumi|nances(G|
|00005110| 44 48 61 6e 64 6c 65 20 | 64 65 76 69 63 65 2c 20 |DHandle |device, |
|00005120| 6c 75 6d 69 6e 61 6e 63 | 65 52 65 63 6f 72 64 20 |luminanc|eRecord |
|00005130| 2a 4c 50 2c 0d 09 69 6e | 74 20 66 69 72 73 74 45 |*LP,..in|t firstE|
|00005140| 6e 74 72 79 2c 20 69 6e | 74 20 6c 61 73 74 45 6e |ntry, in|t lastEn|
|00005150| 74 72 79 29 0d 2f 2a 0d | 54 68 69 73 20 6a 75 73 |try)./*.|This jus|
|00005160| 74 20 63 61 6c 6c 73 20 | 47 44 53 65 74 45 6e 74 |t calls |GDSetEnt|
|00005170| 72 69 65 73 28 29 20 6f | 72 20 47 44 44 69 72 65 |ries() o|r GDDire|
|00005180| 63 74 53 65 74 45 6e 74 | 72 69 65 73 28 29 20 74 |ctSetEnt|ries() t|
|00005190| 6f 20 6c 6f 61 64 20 79 | 6f 75 72 20 43 6f 6c 6f |o load y|our Colo|
|000051a0| 72 53 70 65 63 0d 74 61 | 62 6c 65 20 69 6e 74 6f |rSpec.ta|ble into|
|000051b0| 20 74 68 65 20 63 6c 75 | 74 20 6f 66 20 79 6f 75 | the clu|t of you|
|000051c0| 72 20 73 63 72 65 65 6e | 20 64 65 76 69 63 65 2e |r screen| device.|
|000051d0| 20 49 74 20 69 73 20 68 | 65 72 65 20 73 69 6d 70 | It is h|ere simp|
|000051e0| 6c 79 20 74 6f 20 70 72 | 6f 76 69 64 65 20 61 0d |ly to pr|ovide a.|
|000051f0| 63 6f 73 6d 65 74 69 63 | 20 6d 61 74 63 68 20 74 |cosmetic| match t|
|00005200| 6f 20 74 68 65 20 63 61 | 6c 6c 20 74 6f 20 53 65 |o the ca|ll to Se|
|00005210| 74 4c 75 6d 69 6e 61 6e | 63 65 73 28 29 2c 20 66 |tLuminan|ces(), f|
|00005220| 6f 72 20 77 68 69 63 68 | 20 6c 6f 61 64 69 6e 67 |or which| loading|
|00005230| 20 74 68 65 20 63 6c 75 | 74 20 69 73 0d 6f 70 74 | the clu|t is.opt|
|00005240| 69 6f 6e 61 6c 2e 20 4e | 6f 74 65 3a 20 69 66 20 |ional. N|ote: if |
|00005250| 79 6f 75 20 70 72 65 66 | 65 72 2c 20 69 6e 73 74 |you pref|er, inst|
|00005260| 65 61 64 20 6f 66 20 4c | 50 20 79 6f 75 20 6d 61 |ead of L|P you ma|
|00005270| 79 20 73 65 6e 64 20 6a | 75 73 74 20 74 68 65 20 |y send j|ust the |
|00005280| 61 64 64 72 65 73 73 20 | 6f 66 20 61 0d 43 6f 6c |address |of a.Col|
|00005290| 6f 72 53 70 65 63 20 74 | 61 62 6c 65 2c 20 63 61 |orSpec t|able, ca|
|000052a0| 73 74 20 74 6f 20 28 6c | 75 6d 69 6e 61 6e 63 65 |st to (l|uminance|
|000052b0| 52 65 63 6f 72 64 20 2a | 29 2c 20 73 69 6e 63 65 |Record *|), since|
|000052c0| 20 61 20 6c 75 6d 69 6e | 61 6e 63 65 52 65 63 6f | a lumin|anceReco|
|000052d0| 72 64 20 62 65 67 69 6e | 73 0d 77 69 74 68 20 61 |rd begin|s.with a|
|000052e0| 20 43 6f 6c 6f 72 53 70 | 65 63 20 74 61 62 6c 65 | ColorSp|ec table|
|000052f0| 2e 0d 2a 2f 0d 7b 0d 09 | 69 6e 74 20 65 72 72 6f |..*/.{..|int erro|
|00005300| 72 3b 0d 09 0d 09 73 77 | 69 74 63 68 28 28 2a 64 |r;....sw|itch((*d|
|00005310| 65 76 69 63 65 29 2d 3e | 67 64 54 79 70 65 29 7b |evice)->|gdType){|
|00005320| 0d 09 63 61 73 65 20 66 | 69 78 65 64 54 79 70 65 |..case f|ixedType|
|00005330| 3a 0d 09 09 70 72 69 6e | 74 66 28 22 4c 6f 61 64 |:...prin|tf("Load|
|00005340| 4c 75 6d 69 6e 61 6e 63 | 65 73 3a 20 74 68 69 73 |Luminanc|es: this|
|00005350| 20 64 65 76 69 63 65 20 | 68 61 73 20 61 20 66 69 | device |has a fi|
|00005360| 78 65 64 20 43 4c 55 54 | 2e 5c 6e 22 29 3b 0d 09 |xed CLUT|.\n");..|
|00005370| 09 72 65 74 75 72 6e 3b | 0d 09 63 61 73 65 20 63 |.return;|..case c|
|00005380| 6c 75 74 54 79 70 65 3a | 0d 09 09 65 72 72 6f 72 |lutType:|...error|
|00005390| 3d 47 44 53 65 74 45 6e | 74 72 69 65 73 28 64 65 |=GDSetEn|tries(de|
|000053a0| 76 69 63 65 2c 66 69 72 | 73 74 45 6e 74 72 79 2c |vice,fir|stEntry,|
|000053b0| 6c 61 73 74 45 6e 74 72 | 79 2d 66 69 72 73 74 45 |lastEntr|y-firstE|
|000053c0| 6e 74 72 79 0d 09 09 09 | 2c 26 4c 50 2d 3e 74 61 |ntry....|,&LP->ta|
|000053d0| 62 6c 65 5b 66 69 72 73 | 74 45 6e 74 72 79 5d 29 |ble[firs|tEntry])|
|000053e0| 3b 0d 09 09 62 72 65 61 | 6b 3b 0d 09 63 61 73 65 |;...brea|k;..case|
|000053f0| 20 64 69 72 65 63 74 54 | 79 70 65 3a 0d 09 09 65 | directT|ype:...e|
|00005400| 72 72 6f 72 3d 47 44 44 | 69 72 65 63 74 53 65 74 |rror=GDD|irectSet|
|00005410| 45 6e 74 72 69 65 73 28 | 64 65 76 69 63 65 2c 66 |Entries(|device,f|
|00005420| 69 72 73 74 45 6e 74 72 | 79 2c 6c 61 73 74 45 6e |irstEntr|y,lastEn|
|00005430| 74 72 79 2d 66 69 72 73 | 74 45 6e 74 72 79 0d 09 |try-firs|tEntry..|
|00005440| 09 09 2c 26 4c 50 2d 3e | 74 61 62 6c 65 5b 66 69 |..,&LP->|table[fi|
|00005450| 72 73 74 45 6e 74 72 79 | 5d 29 3b 0d 09 09 62 72 |rstEntry|]);...br|
|00005460| 65 61 6b 3b 0d 09 7d 0d | 09 69 66 28 65 72 72 6f |eak;..}.|.if(erro|
|00005470| 72 29 20 70 72 69 6e 74 | 66 28 22 5c 30 30 37 4c |r) print|f("\007L|
|00005480| 6f 61 64 4c 75 6d 69 6e | 61 6e 63 65 73 3a 20 65 |oadLumin|ances: e|
|00005490| 72 72 6f 72 20 25 64 5c | 6e 22 2c 65 72 72 6f 72 |rror %d\|n",error|
|000054a0| 29 3b 0d 7d 0d 0d 64 6f | 75 62 6c 65 20 4c 54 6f |);.}..do|uble LTo|
|000054b0| 4c 28 6c 75 6d 69 6e 61 | 6e 63 65 52 65 63 6f 72 |L(lumina|nceRecor|
|000054c0| 64 20 2a 4c 50 2c 64 6f | 75 62 6c 65 20 4c 29 0d |d *LP,do|uble L).|
|000054d0| 7b 0d 09 69 66 28 4c 20 | 3e 20 4c 50 2d 3e 4c 4d |{..if(L |> LP->LM|
|000054e0| 61 78 29 20 72 65 74 75 | 72 6e 20 4c 50 2d 3e 4c |ax) retu|rn LP->L|
|000054f0| 4d 61 78 3b 0d 09 69 66 | 28 4c 20 3c 20 4c 50 2d |Max;..if|(L < LP-|
|00005500| 3e 4c 4d 69 6e 29 20 72 | 65 74 75 72 6e 20 4c 50 |>LMin) r|eturn LP|
|00005510| 2d 3e 4c 4d 69 6e 3b 0d | 09 72 65 74 75 72 6e 20 |->LMin;.|.return |
|00005520| 4c 3b 0d 7d 0d 0d 64 6f | 75 62 6c 65 20 56 54 6f |L;.}..do|uble VTo|
|00005530| 4c 28 6c 75 6d 69 6e 61 | 6e 63 65 52 65 63 6f 72 |L(lumina|nceRecor|
|00005540| 64 20 2a 4c 50 2c 64 6f | 75 62 6c 65 20 56 29 0d |d *LP,do|uble V).|
|00005550| 2f 2a 0d 52 65 74 75 72 | 6e 20 74 68 65 20 6c 75 |/*.Retur|n the lu|
|00005560| 6d 69 6e 61 6e 63 65 20 | 74 68 61 74 20 77 6f 75 |minance |that wou|
|00005570| 6c 64 20 72 65 73 75 6c | 74 20 66 72 6f 6d 20 61 |ld resul|t from a|
|00005580| 20 6e 6f 6d 69 6e 61 6c | 20 76 6f 6c 74 61 67 65 | nominal| voltage|
|00005590| 2e 0d 2a 2f 0d 7b 0d 09 | 72 65 74 75 72 6e 20 46 |..*/.{..|return F|
|000055a0| 69 78 54 6f 44 6f 75 62 | 6c 65 28 5f 56 54 6f 4c |ixToDoub|le(_VToL|
|000055b0| 28 4c 50 2c 44 6f 75 62 | 6c 65 54 6f 46 69 78 28 |(LP,Doub|leToFix(|
|000055c0| 56 29 29 29 3b 0d 7d 0d | 0d 46 49 58 45 44 20 5f |V)));.}.|.FIXED _|
|000055d0| 56 54 6f 4c 28 6c 75 6d | 69 6e 61 6e 63 65 52 65 |VToL(lum|inanceRe|
|000055e0| 63 6f 72 64 20 2a 4c 50 | 2c 46 49 58 45 44 20 5f |cord *LP|,FIXED _|
|000055f0| 56 29 0d 2f 2a 0d 52 65 | 74 75 72 6e 20 74 68 65 |V)./*.Re|turn the|
|00005600| 20 6c 75 6d 69 6e 61 6e | 63 65 20 74 68 61 74 20 | luminan|ce that |
|00005610| 77 6f 75 6c 64 20 72 65 | 73 75 6c 74 20 66 72 6f |would re|sult fro|
|00005620| 6d 20 61 20 6e 6f 6d 69 | 6e 61 6c 20 76 6f 6c 74 |m a nomi|nal volt|
|00005630| 61 67 65 2e 0d 2a 2f 0d | 7b 0d 09 72 65 67 69 73 |age..*/.|{..regis|
|00005640| 74 65 72 20 69 6e 74 20 | 69 3b 0d 09 72 65 67 69 |ter int |i;..regi|
|00005650| 73 74 65 72 20 6c 75 6d | 69 6e 61 6e 63 65 54 61 |ster lum|inanceTa|
|00005660| 62 6c 65 20 2a 4c 54 3b | 0d 09 72 65 67 69 73 74 |ble *LT;|..regist|
|00005670| 65 72 20 46 49 58 45 44 | 20 5f 64 69 3b 0d 09 64 |er FIXED| _di;..d|
|00005680| 6f 75 62 6c 65 20 4c 46 | 2c 56 46 3b 0d 09 0d 09 |ouble LF|,VF;....|
|00005690| 4c 54 3d 26 4c 50 2d 3e | 4c 3b 0d 09 69 66 28 4c |LT=&LP->|L;..if(L|
|000056a0| 54 2d 3e 65 78 69 73 74 | 73 3d 3d 6c 75 6d 69 6e |T->exist|s==lumin|
|000056b0| 61 6e 63 65 53 65 74 29 | 7b 0d 09 09 5f 64 69 3d |anceSet)|{..._di=|
|000056c0| 46 69 78 44 69 76 28 5f | 56 2d 4c 54 2d 3e 5f 56 |FixDiv(_|V-LT->_V|
|000056d0| 4d 69 6e 2c 4c 54 2d 3e | 5f 64 56 29 3b 0d 09 09 |Min,LT->|_dV);...|
|000056e0| 69 3d 46 69 78 54 6f 4c | 6f 6e 67 28 5f 64 69 29 |i=FixToL|ong(_di)|
|000056f0| 3b 0d 09 09 5f 64 69 20 | 2d 3d 20 4c 6f 6e 67 54 |;..._di |-= LongT|
|00005700| 6f 46 69 78 28 69 29 3b | 0d 09 09 69 66 28 69 3c |oFix(i);|...if(i<|
|00005710| 30 29 72 65 74 75 72 6e | 20 4c 54 2d 3e 5f 4c 5b |0)return| LT->_L[|
|00005720| 30 5d 3b 0d 09 09 69 66 | 28 69 3e 3d 4c 55 4d 49 |0];...if|(i>=LUMI|
|00005730| 4e 41 4e 43 45 53 5f 49 | 4e 5f 54 41 42 4c 45 2d |NANCES_I|N_TABLE-|
|00005740| 31 29 72 65 74 75 72 6e | 20 4c 54 2d 3e 5f 4c 5b |1)return| LT->_L[|
|00005750| 4c 55 4d 49 4e 41 4e 43 | 45 53 5f 49 4e 5f 54 41 |LUMINANC|ES_IN_TA|
|00005760| 42 4c 45 2d 31 5d 3b 0d | 09 09 72 65 74 75 72 6e |BLE-1];.|..return|
|00005770| 20 4c 54 2d 3e 5f 4c 5b | 69 5d 2b 46 69 78 4d 75 | LT->_L[|i]+FixMu|
|00005780| 6c 28 5f 64 69 2c 4c 54 | 2d 3e 5f 4c 5b 69 2b 31 |l(_di,LT|->_L[i+1|
|00005790| 5d 2d 4c 54 2d 3e 5f 4c | 5b 69 5d 29 3b 0d 09 7d |]-LT->_L|[i]);..}|
|000057a0| 0d 09 56 46 3d 46 69 78 | 54 6f 44 6f 75 62 6c 65 |..VF=Fix|ToDouble|
|000057b0| 28 5f 56 29 3b 0d 09 69 | 66 28 4c 50 2d 3e 70 6f |(_V);..i|f(LP->po|
|000057c0| 77 65 72 45 72 72 6f 72 | 20 3c 20 32 2e 30 2a 4c |werError| < 2.0*L|
|000057d0| 50 2d 3e 70 6f 6c 79 6e | 6f 6d 69 61 6c 45 72 72 |P->polyn|omialErr|
|000057e0| 6f 72 29 20 4c 46 3d 56 | 54 6f 4c 50 6f 77 65 72 |or) LF=V|ToLPower|
|000057f0| 28 4c 50 2c 56 46 29 3b | 0d 09 65 6c 73 65 20 4c |(LP,VF);|..else L|
|00005800| 46 3d 56 54 6f 4c 50 6f | 6c 79 6e 6f 6d 69 61 6c |F=VToLPo|lynomial|
|00005810| 28 4c 50 2c 56 46 29 3b | 0d 09 72 65 74 75 72 6e |(LP,VF);|..return|
|00005820| 20 44 6f 75 62 6c 65 54 | 6f 46 69 78 28 4c 46 29 | DoubleT|oFix(LF)|
|00005830| 3b 0d 7d 0d 0d 64 6f 75 | 62 6c 65 20 4c 54 6f 56 |;.}..dou|ble LToV|
|00005840| 28 6c 75 6d 69 6e 61 6e | 63 65 52 65 63 6f 72 64 |(luminan|ceRecord|
|00005850| 20 2a 4c 50 2c 64 6f 75 | 62 6c 65 20 4c 29 0d 7b | *LP,dou|ble L).{|
|00005860| 0d 09 72 65 74 75 72 6e | 20 46 69 78 54 6f 44 6f |..return| FixToDo|
|00005870| 75 62 6c 65 28 5f 4c 54 | 6f 56 28 4c 50 2c 44 6f |uble(_LT|oV(LP,Do|
|00005880| 75 62 6c 65 54 6f 46 69 | 78 28 4c 29 29 29 3b 0d |ubleToFi|x(L)));.|
|00005890| 7d 0d 0d 46 49 58 45 44 | 20 5f 4c 54 6f 56 28 6c |}..FIXED| _LToV(l|
|000058a0| 75 6d 69 6e 61 6e 63 65 | 52 65 63 6f 72 64 20 2a |uminance|Record *|
|000058b0| 4c 50 2c 46 49 58 45 44 | 20 5f 4c 29 0d 2f 2a 0d |LP,FIXED| _L)./*.|
|000058c0| 4e 65 77 2c 20 66 61 73 | 74 65 72 20 76 65 72 73 |New, fas|ter vers|
|000058d0| 69 6f 6e 20 75 73 65 73 | 20 61 20 74 61 62 75 6c |ion uses| a tabul|
|000058e0| 61 74 65 64 20 76 65 72 | 73 69 6f 6e 20 6f 66 20 |ated ver|sion of |
|000058f0| 74 68 65 20 67 61 6d 6d | 61 20 66 75 6e 63 74 69 |the gamm|a functi|
|00005900| 6f 6e 20 56 54 6f 4c 28 | 29 2e 20 54 68 69 73 0d |on VToL(|). This.|
|00005910| 72 65 70 6c 61 63 65 73 | 20 74 68 65 20 6f 6c 64 |replaces| the old|
|00005920| 20 66 75 6e 63 74 69 6f | 6e 20 4c 54 6f 56 46 6f | functio|n LToVFo|
|00005930| 72 6d 75 6c 61 69 63 28 | 29 2c 20 66 6f 72 6d 65 |rmulaic(|), forme|
|00005940| 72 6c 79 20 63 61 6c 6c | 65 64 20 4c 54 6f 56 28 |rly call|ed LToV(|
|00005950| 29 2e 20 41 20 73 75 62 | 74 6c 65 74 79 20 69 73 |). A sub|tlety is|
|00005960| 0d 74 68 61 74 20 49 20 | 74 61 62 75 6c 61 74 65 |.that I |tabulate|
|00005970| 20 74 68 65 20 67 61 6d | 6d 61 20 66 75 6e 63 74 | the gam|ma funct|
|00005980| 69 6f 6e 20 5f 4c 5b 5d | 3d 56 54 6f 4c 28 29 20 |ion _L[]|=VToL() |
|00005990| 72 61 74 68 65 72 20 74 | 68 61 6e 20 69 74 73 20 |rather t|han its |
|000059a0| 69 6e 76 65 72 73 65 2c | 20 62 65 63 61 75 73 65 |inverse,| because|
|000059b0| 0d 74 68 69 73 20 79 69 | 65 6c 64 73 20 61 20 6d |.this yi|elds a m|
|000059c0| 75 63 68 20 6c 6f 77 65 | 72 20 75 70 70 65 72 20 |uch lowe|r upper |
|000059d0| 62 6f 75 6e 64 20 6f 6e | 20 74 68 65 20 65 72 72 |bound on| the err|
|000059e0| 6f 72 20 6f 66 20 74 68 | 65 20 6c 69 6e 65 61 72 |or of th|e linear|
|000059f0| 6c 79 20 69 6e 74 65 72 | 70 6f 6c 61 74 65 64 0d |ly inter|polated.|
|00005a00| 4c 2e 20 54 68 69 73 20 | 69 73 20 74 72 75 65 20 |L. This |is true |
|00005a10| 62 65 63 61 75 73 65 20 | 74 68 65 20 67 61 6d 6d |because |the gamm|
|00005a20| 61 20 66 75 6e 63 74 69 | 6f 6e 20 69 73 20 72 6f |a functi|on is ro|
|00005a30| 75 67 68 6c 79 20 70 61 | 72 61 62 6f 6c 69 63 2e |ughly pa|rabolic.|
|00005a40| 20 45 71 75 61 6c 6c 79 | 20 73 70 61 63 65 64 0d | Equally| spaced.|
|00005a50| 73 61 6d 70 6c 65 73 20 | 6f 66 20 61 20 70 61 72 |samples |of a par|
|00005a60| 61 62 6f 6c 69 63 20 66 | 75 6e 63 74 69 6f 6e 20 |abolic f|unction |
|00005a70| 79 69 65 6c 64 20 65 71 | 75 61 6c 20 6d 61 78 69 |yield eq|ual maxi|
|00005a80| 6d 75 6d 20 65 72 72 6f | 72 20 6f 66 20 6c 69 6e |mum erro|r of lin|
|00005a90| 65 61 72 0d 69 6e 74 65 | 72 70 6f 6c 61 74 69 6f |ear.inte|rpolatio|
|00005aa0| 6e 20 69 6e 20 61 6c 6c | 20 69 6e 74 65 72 76 61 |n in all| interva|
|00005ab0| 6c 73 2e 20 54 68 65 20 | 63 6f 73 74 20 6f 66 20 |ls. The |cost of |
|00005ac0| 74 61 62 75 6c 61 74 69 | 6e 67 20 5f 4c 5b 5d 20 |tabulati|ng _L[] |
|00005ad0| 72 61 74 68 65 72 20 74 | 68 61 6e 20 69 74 73 0d |rather t|han its.|
|00005ae0| 69 6e 76 65 72 73 65 20 | 69 73 20 74 68 61 74 20 |inverse |is that |
|00005af0| 77 65 20 6d 75 73 74 20 | 73 65 61 72 63 68 20 74 |we must |search t|
|00005b00| 68 65 20 74 61 62 6c 65 | 20 69 6e 20 6f 72 64 65 |he table| in orde|
|00005b10| 72 20 74 6f 20 66 69 6e | 64 20 74 68 65 20 6c 61 |r to fin|d the la|
|00005b20| 72 67 65 73 74 20 5f 4c | 5b 5d 20 6c 65 73 73 0d |rgest _L|[] less.|
|00005b30| 74 68 61 6e 20 6f 72 20 | 65 71 75 61 6c 20 74 6f |than or |equal to|
|00005b40| 20 4c 2e 20 54 68 65 20 | 73 65 61 72 63 68 20 74 | L. The |search t|
|00005b50| 69 6d 65 20 69 73 20 6d | 69 6e 69 6d 69 7a 65 64 |ime is m|inimized|
|00005b60| 20 62 79 20 75 73 69 6e | 67 20 61 20 73 65 61 72 | by usin|g a sear|
|00005b70| 63 68 20 70 72 6f 63 65 | 64 75 72 65 0d 74 68 61 |ch proce|dure.tha|
|00005b80| 74 20 62 65 67 69 6e 73 | 20 74 68 65 20 73 65 61 |t begins| the sea|
|00005b90| 72 63 68 20 61 74 20 74 | 68 65 20 70 6c 61 63 65 |rch at t|he place|
|00005ba0| 20 66 6f 75 6e 64 20 62 | 79 20 74 68 65 20 6c 61 | found b|y the la|
|00005bb0| 73 74 20 73 65 61 72 63 | 68 2c 20 73 69 6e 63 65 |st searc|h, since|
|00005bc0| 20 73 75 63 63 65 73 73 | 69 76 65 0d 63 61 6c 6c | success|ive.call|
|00005bd0| 73 20 74 6f 20 4c 54 6f | 56 28 29 20 61 72 65 20 |s to LTo|V() are |
|00005be0| 6c 69 6b 65 6c 79 20 74 | 6f 20 72 65 71 75 65 73 |likely t|o reques|
|00005bf0| 74 20 73 69 6d 69 6c 61 | 72 20 6c 75 6d 69 6e 61 |t simila|r lumina|
|00005c00| 6e 63 65 73 2e 0d 2a 2f | 0d 7b 0d 09 72 65 67 69 |nces..*/|.{..regi|
|00005c10| 73 74 65 72 20 6c 75 6d | 69 6e 61 6e 63 65 54 61 |ster lum|inanceTa|
|00005c20| 62 6c 65 20 2a 4c 54 3b | 0d 09 72 65 67 69 73 74 |ble *LT;|..regist|
|00005c30| 65 72 20 69 6e 74 20 6c | 6f 2c 68 69 2c 69 3b 0d |er int l|o,hi,i;.|
|00005c40| 09 72 65 67 69 73 74 65 | 72 20 46 49 58 45 44 20 |.registe|r FIXED |
|00005c50| 5f 64 4c 2c 5f 64 4c 54 | 65 6d 70 3b 0d 09 46 49 |_dL,_dLT|emp;..FI|
|00005c60| 58 45 44 20 5f 56 2c 5f | 4c 4c 6f 3b 0d 09 0d 09 |XED _V,_|LLo;....|
|00005c70| 4c 54 3d 26 4c 50 2d 3e | 4c 3b 0d 09 69 66 28 4c |LT=&LP->|L;..if(L|
|00005c80| 54 2d 3e 65 78 69 73 74 | 73 20 21 3d 20 6c 75 6d |T->exist|s != lum|
|00005c90| 69 6e 61 6e 63 65 53 65 | 74 29 7b 0d 09 09 2f 2a |inanceSe|t){.../*|
|00005ca0| 20 67 65 74 20 64 6f 6d | 61 69 6e 20 6f 66 20 74 | get dom|ain of t|
|00005cb0| 68 65 20 6d 6f 6e 6f 74 | 6f 6e 69 63 20 73 65 63 |he monot|onic sec|
|00005cc0| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 67 61 6d 6d |tion of |the gamm|
|00005cd0| 61 20 66 75 6e 63 74 69 | 6f 6e 20 2a 2f 0d 09 09 |a functi|on */...|
|00005ce0| 4c 54 2d 3e 5f 56 4d 69 | 6e 3d 44 6f 75 62 6c 65 |LT->_VMi|n=Double|
|00005cf0| 54 6f 46 69 78 28 4c 54 | 6f 56 46 6f 72 6d 75 6c |ToFix(LT|oVFormul|
|00005d00| 61 69 63 28 4c 50 2c 4c | 50 2d 3e 4c 4d 69 6e 29 |aic(LP,L|P->LMin)|
|00005d10| 29 3b 0d 09 09 4c 54 2d | 3e 5f 56 4d 61 78 3d 44 |);...LT-|>_VMax=D|
|00005d20| 6f 75 62 6c 65 54 6f 46 | 69 78 28 4c 54 6f 56 46 |oubleToF|ix(LToVF|
|00005d30| 6f 72 6d 75 6c 61 69 63 | 28 4c 50 2c 4c 50 2d 3e |ormulaic|(LP,LP->|
|00005d40| 4c 4d 61 78 29 29 3b 0d | 09 09 4c 54 2d 3e 5f 64 |LMax));.|..LT->_d|
|00005d50| 56 3d 28 4c 54 2d 3e 5f | 56 4d 61 78 2d 4c 54 2d |V=(LT->_|VMax-LT-|
|00005d60| 3e 5f 56 4d 69 6e 29 2f | 28 4c 55 4d 49 4e 41 4e |>_VMin)/|(LUMINAN|
|00005d70| 43 45 53 5f 49 4e 5f 54 | 41 42 4c 45 2d 31 29 3b |CES_IN_T|ABLE-1);|
|00005d80| 0d 09 09 5f 56 3d 4c 54 | 2d 3e 5f 56 4d 69 6e 3b |..._V=LT|->_VMin;|
|00005d90| 0d 09 09 66 6f 72 28 69 | 3d 30 3b 69 3c 4c 55 4d |...for(i|=0;i<LUM|
|00005da0| 49 4e 41 4e 43 45 53 5f | 49 4e 5f 54 41 42 4c 45 |INANCES_|IN_TABLE|
|00005db0| 3b 69 2b 2b 2c 5f 56 2b | 3d 4c 54 2d 3e 5f 64 56 |;i++,_V+|=LT->_dV|
|00005dc0| 29 20 4c 54 2d 3e 5f 4c | 5b 69 5d 3d 5f 56 54 6f |) LT->_L|[i]=_VTo|
|00005dd0| 4c 28 4c 50 2c 5f 56 29 | 3b 0d 09 09 2f 2a 20 6a |L(LP,_V)|;.../* j|
|00005de0| 75 73 74 20 69 6e 20 63 | 61 73 65 2c 20 69 6d 70 |ust in c|ase, imp|
|00005df0| 6f 73 65 20 6d 6f 6e 6f | 74 6f 6e 69 63 69 74 79 |ose mono|tonicity|
|00005e00| 2c 20 66 72 6f 6d 20 63 | 65 6e 74 65 72 20 6f 6e |, from c|enter on|
|00005e10| 20 6f 75 74 20 2a 2f 0d | 09 09 66 6f 72 28 69 3d | out */.|..for(i=|
|00005e20| 4c 55 4d 49 4e 41 4e 43 | 45 53 5f 49 4e 5f 54 41 |LUMINANC|ES_IN_TA|
|00005e30| 42 4c 45 2f 32 3b 69 3e | 30 3b 69 2d 2d 29 0d 09 |BLE/2;i>|0;i--)..|
|00005e40| 09 09 69 66 28 4c 54 2d | 3e 5f 4c 5b 69 2d 31 5d |..if(LT-|>_L[i-1]|
|00005e50| 20 3e 20 4c 54 2d 3e 5f | 4c 5b 69 5d 29 20 4c 54 | > LT->_|L[i]) LT|
|00005e60| 2d 3e 5f 4c 5b 69 2d 31 | 5d 3d 4c 54 2d 3e 5f 4c |->_L[i-1|]=LT->_L|
|00005e70| 5b 69 5d 3b 0d 09 09 66 | 6f 72 28 69 3d 31 2b 4c |[i];...f|or(i=1+L|
|00005e80| 55 4d 49 4e 41 4e 43 45 | 53 5f 49 4e 5f 54 41 42 |UMINANCE|S_IN_TAB|
|00005e90| 4c 45 2f 32 3b 69 3c 4c | 55 4d 49 4e 41 4e 43 45 |LE/2;i<L|UMINANCE|
|00005ea0| 53 5f 49 4e 5f 54 41 42 | 4c 45 3b 69 2b 2b 29 0d |S_IN_TAB|LE;i++).|
|00005eb0| 09 09 09 69 66 28 4c 54 | 2d 3e 5f 4c 5b 69 2d 31 |...if(LT|->_L[i-1|
|00005ec0| 5d 20 3e 20 4c 54 2d 3e | 5f 4c 5b 69 5d 29 20 4c |] > LT->|_L[i]) L|
|00005ed0| 54 2d 3e 5f 4c 5b 69 5d | 3d 4c 54 2d 3e 5f 4c 5b |T->_L[i]|=LT->_L[|
|00005ee0| 69 2d 31 5d 3b 0d 09 09 | 23 69 66 20 46 41 53 54 |i-1];...|#if FAST|
|00005ef0| 5f 4c 55 4d 49 4e 41 4e | 43 45 09 2f 2a 20 63 6f |_LUMINAN|CE./* co|
|00005f00| 6d 70 75 74 65 20 74 68 | 65 20 73 6c 6f 70 65 20 |mpute th|e slope |
|00005f10| 64 4c 2f 64 56 20 2a 2f | 0d 09 09 09 2f 2a 20 66 |dL/dV */|..../* f|
|00005f20| 69 6e 64 20 73 68 69 66 | 74 20 74 68 61 74 20 6d |ind shif|t that m|
|00005f30| 61 78 69 6d 69 7a 65 73 | 20 c6 4c 20 70 72 65 63 |aximizes| .L prec|
|00005f40| 69 73 69 6f 6e 20 77 69 | 74 68 6f 75 74 20 6f 76 |ision wi|thout ov|
|00005f50| 65 72 66 6c 6f 77 20 2a | 2f 0d 09 09 09 5f 64 4c |erflow *|/...._dL|
|00005f60| 3d 30 3b 0d 09 09 09 66 | 6f 72 28 69 3d 30 3b 69 |=0;....f|or(i=0;i|
|00005f70| 3c 4c 55 4d 49 4e 41 4e | 43 45 53 5f 49 4e 5f 54 |<LUMINAN|CES_IN_T|
|00005f80| 41 42 4c 45 2d 31 3b 69 | 2b 2b 29 7b 0d 09 09 09 |ABLE-1;i|++){....|
|00005f90| 09 5f 64 4c 54 65 6d 70 | 3d 4c 54 2d 3e 5f 4c 5b |._dLTemp|=LT->_L[|
|00005fa0| 69 2b 31 5d 2d 4c 54 2d | 3e 5f 4c 5b 69 5d 3b 0d |i+1]-LT-|>_L[i];.|
|00005fb0| 09 09 09 09 69 66 28 5f | 64 4c 3c 5f 64 4c 54 65 |....if(_|dL<_dLTe|
|00005fc0| 6d 70 29 5f 64 4c 3d 5f | 64 4c 54 65 6d 70 3b 0d |mp)_dL=_|dLTemp;.|
|00005fd0| 09 09 09 7d 0d 09 09 09 | 4c 54 2d 3e 4c 53 68 69 |...}....|LT->LShi|
|00005fe0| 66 74 3d 4c 6f 67 32 4c | 28 4c 4f 4e 47 5f 4d 41 |ft=Log2L|(LONG_MA|
|00005ff0| 58 2f 5f 64 4c 29 3b 0d | 09 09 23 65 6e 64 69 66 |X/_dL);.|..#endif|
|00006000| 09 09 09 09 0d 09 09 4c | 54 2d 3e 65 78 69 73 74 |.......L|T->exist|
|00006010| 73 3d 6c 75 6d 69 6e 61 | 6e 63 65 53 65 74 3b 0d |s=lumina|nceSet;.|
|00006020| 09 09 4c 54 2d 3e 6c 61 | 74 65 73 74 49 6e 64 65 |..LT->la|testInde|
|00006030| 78 3d 2d 32 3b 09 2f 2a | 20 69 6e 76 61 6c 69 64 |x=-2;./*| invalid|
|00006040| 2c 20 73 6f 20 68 75 6e | 74 20 77 69 6c 6c 20 73 |, so hun|t will s|
|00006050| 74 61 72 74 20 66 72 6f | 6d 20 73 63 72 61 74 63 |tart fro|m scratc|
|00006060| 68 20 2a 2f 0d 09 7d 0d | 09 2f 2a 20 68 75 6e 74 |h */..}.|./* hunt|
|00006070| 20 66 6f 72 20 4c 20 69 | 6e 20 4c 54 2d 3e 5f 4c | for L i|n LT->_L|
|00006080| 5b 5d 20 2a 2f 0d 09 2f | 2a 20 66 69 72 73 74 20 |[] */../|* first |
|00006090| 63 68 65 63 6b 20 61 74 | 20 6c 61 74 65 73 74 49 |check at| latestI|
|000060a0| 6e 64 65 78 2c 20 6c 61 | 74 65 73 74 49 6e 64 65 |ndex, la|testInde|
|000060b0| 78 b1 31 2c 20 2e 2e 2e | 20 2a 2f 0d 09 6c 6f 3d |x.1, ...| */..lo=|
|000060c0| 2d 31 3b 0d 09 68 69 3d | 4c 55 4d 49 4e 41 4e 43 |-1;..hi=|LUMINANC|
|000060d0| 45 53 5f 49 4e 5f 54 41 | 42 4c 45 3b 0d 09 69 3d |ES_IN_TA|BLE;..i=|
|000060e0| 4c 54 2d 3e 6c 61 74 65 | 73 74 49 6e 64 65 78 3b |LT->late|stIndex;|
|000060f0| 0d 09 69 66 28 69 3e 6c | 6f 20 26 26 20 69 3c 68 |..if(i>l|o && i<h|
|00006100| 69 29 7b 0d 09 09 69 66 | 28 5f 4c 3e 4c 54 2d 3e |i){...if|(_L>LT->|
|00006110| 5f 4c 5b 69 5d 29 0d 09 | 09 09 7b 6c 6f 3d 69 3b |_L[i])..|..{lo=i;|
|00006120| 69 2b 2b 3b 7d 0d 09 09 | 65 6c 73 65 0d 09 09 09 |i++;}...|else....|
|00006130| 7b 68 69 3d 69 3b 69 2d | 2d 3b 7d 0d 09 7d 0d 09 |{hi=i;i-|-;}..}..|
|00006140| 2f 2a 20 73 69 6d 70 6c | 65 20 62 69 73 65 63 74 |/* simpl|e bisect|
|00006150| 69 6f 6e 20 73 65 61 72 | 63 68 2c 20 73 65 65 20 |ion sear|ch, see |
|00006160| 4e 75 6d 65 72 69 63 61 | 6c 20 52 65 63 69 70 65 |Numerica|l Recipe|
|00006170| 73 20 69 6e 20 43 2c 20 | 70 61 67 65 73 20 39 38 |s in C, |pages 98|
|00006180| 2d 39 39 2e 20 2a 2f 0d | 09 77 68 69 6c 65 28 68 |-99. */.|.while(h|
|00006190| 69 2d 6c 6f 3e 31 29 7b | 0d 09 09 69 3d 28 68 69 |i-lo>1){|...i=(hi|
|000061a0| 2b 6c 6f 29 3e 3e 31 3b | 0d 09 09 69 66 28 5f 4c |+lo)>>1;|...if(_L|
|000061b0| 3e 4c 54 2d 3e 5f 4c 5b | 69 5d 29 6c 6f 3d 69 3b |>LT->_L[|i])lo=i;|
|000061c0| 0d 09 09 65 6c 73 65 20 | 68 69 3d 69 3b 0d 09 7d |...else |hi=i;..}|
|000061d0| 0d 09 4c 54 2d 3e 6c 61 | 74 65 73 74 49 6e 64 65 |..LT->la|testInde|
|000061e0| 78 3d 6c 6f 3b 0d 09 69 | 66 28 6c 6f 3c 30 29 7b |x=lo;..i|f(lo<0){|
|000061f0| 0d 09 09 4c 54 2d 3e 6c | 61 74 65 73 74 49 6e 64 |...LT->l|atestInd|
|00006200| 65 78 3d 30 3b 09 09 09 | 2f 2a 20 6e 65 61 72 65 |ex=0;...|/* neare|
|00006210| 73 74 20 6c 65 67 61 6c | 20 69 6e 64 65 78 20 2a |st legal| index *|
|00006220| 2f 0d 09 09 72 65 74 75 | 72 6e 20 4c 54 2d 3e 5f |/...retu|rn LT->_|
|00006230| 56 4d 69 6e 3b 0d 09 7d | 0d 09 69 66 28 6c 6f 3e |VMin;..}|..if(lo>|
|00006240| 3d 4c 55 4d 49 4e 41 4e | 43 45 53 5f 49 4e 5f 54 |=LUMINAN|CES_IN_T|
|00006250| 41 42 4c 45 2d 31 29 72 | 65 74 75 72 6e 20 4c 54 |ABLE-1)r|eturn LT|
|00006260| 2d 3e 5f 56 4d 61 78 3b | 0d 09 5f 4c 4c 6f 3d 4c |->_VMax;|.._LLo=L|
|00006270| 54 2d 3e 5f 4c 5b 6c 6f | 5d 3b 0d 09 5f 64 4c 3d |T->_L[lo|];.._dL=|
|00006280| 5f 4c 2d 5f 4c 4c 6f 3b | 0d 09 23 69 66 20 46 41 |_L-_LLo;|..#if FA|
|00006290| 53 54 5f 4c 55 4d 49 4e | 41 4e 43 45 0d 09 09 72 |ST_LUMIN|ANCE...r|
|000062a0| 65 74 75 72 6e 20 4c 54 | 2d 3e 5f 56 4d 69 6e 2b |eturn LT|->_VMin+|
|000062b0| 6c 6f 2a 4c 54 2d 3e 5f | 64 56 0d 09 09 09 2b 28 |lo*LT->_|dV....+(|
|000062c0| 5f 64 4c 3c 3c 4c 54 2d | 3e 4c 53 68 69 66 74 29 |_dL<<LT-|>LShift)|
|000062d0| 2f 28 28 4c 54 2d 3e 5f | 4c 5b 6c 6f 2b 31 5d 2d |/((LT->_|L[lo+1]-|
|000062e0| 5f 4c 4c 6f 3c 3c 4c 54 | 2d 3e 4c 53 68 69 66 74 |_LLo<<LT|->LShift|
|000062f0| 29 2f 4c 54 2d 3e 5f 64 | 56 29 3b 0d 09 23 65 6c |)/LT->_d|V);..#el|
|00006300| 73 65 0d 09 09 72 65 74 | 75 72 6e 20 4c 54 2d 3e |se...ret|urn LT->|
|00006310| 5f 56 4d 69 6e 2b 4c 54 | 2d 3e 5f 64 56 2a 28 6c |_VMin+LT|->_dV*(l|
|00006320| 6f 2b 5f 64 4c 2f 28 4c | 54 2d 3e 5f 4c 5b 6c 6f |o+_dL/(L|T->_L[lo|
|00006330| 2b 31 5d 2d 5f 4c 4c 6f | 29 29 3b 0d 09 23 65 6e |+1]-_LLo|));..#en|
|00006340| 64 69 66 0d 7d 0d 0d 64 | 6f 75 62 6c 65 20 4c 54 |dif.}..d|ouble LT|
|00006350| 6f 56 46 6f 72 6d 75 6c | 61 69 63 28 6c 75 6d 69 |oVFormul|aic(lumi|
|00006360| 6e 61 6e 63 65 52 65 63 | 6f 72 64 20 2a 4c 50 2c |nanceRec|ord *LP,|
|00006370| 64 6f 75 62 6c 65 20 4c | 29 0d 2f 2a 0d 46 69 6e |double L|)./*.Fin|
|00006380| 64 20 61 20 6e 6f 6d 69 | 6e 61 6c 20 76 6f 6c 74 |d a nomi|nal volt|
|00006390| 61 67 65 20 74 68 61 74 | 20 77 6f 75 6c 64 20 67 |age that| would g|
|000063a0| 69 76 65 20 6c 75 6d 69 | 6e 61 6e 63 65 20 4c 2e |ive lumi|nance L.|
|000063b0| 20 46 61 69 6c 69 6e 67 | 20 74 68 61 74 2c 20 69 | Failing| that, i|
|000063c0| 74 20 72 65 74 75 72 6e | 73 20 74 68 65 0d 63 6c |t return|s the.cl|
|000063d0| 6f 73 65 73 74 20 70 6f | 73 73 69 62 6c 65 20 76 |osest po|ssible v|
|000063e0| 61 6c 75 65 2e 20 54 68 | 65 20 61 6e 73 77 65 72 |alue. Th|e answer|
|000063f0| 20 69 73 20 63 6f 6d 70 | 75 74 65 64 20 62 79 20 | is comp|uted by |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.